Skip to content

Commit 09692f5

Browse files
committed
build: remove duplicate C++ standard flags from LIEF
LIEF's lief.gyp explicitly sets -std=gnu++17 in cflags_cc and xcode_settings, while common.gypi already sets -std=gnu++20 project-wide. This results in both flags being passed to the compiler (-std=gnu++20 -std=gnu++17). Since the last flag wins, LIEF was silently compiling as C++17 instead of the intended project-wide C++20. Remove the explicit -std=gnu++17 flags from cflags_cc and xcode_settings.OTHER_CPLUSPLUSFLAGS, and the msvs_settings LanguageStandard override (stdcpp17), so LIEF uses the project-wide C++20 standard. Additionally, fix LIEF compilation with C++20 by explicitly qualifying fmt::format and fmt::join in Section.cpp, and converting joined views into std::string values prior to passing them into final formatting calls. This prevents conflicts between fmt::join_view and std::format when compiling under C++20. Fixes: #62129
1 parent d0fa608 commit 09692f5

File tree

7 files changed

+9
-17
lines changed

7 files changed

+9
-17
lines changed

deps/LIEF/lief.gyp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,7 @@
453453
'cflags': [
454454
'-fPIC'
455455
],
456-
# We need c++17 to compile without std::format and avoid conflicts with spdlog.
457-
'msvs_settings': {
458-
'VCCLCompilerTool': {
459-
'LanguageStandard': 'stdcpp17',
460-
},
461-
},
462456
'cflags_cc': [
463-
'-std=gnu++17',
464457
'-fPIC',
465458
'-fvisibility=hidden',
466459
'-fvisibility-inlines-hidden',
@@ -473,7 +466,6 @@
473466
],
474467
'xcode_settings': {
475468
'OTHER_CPLUSPLUSFLAGS': [
476-
'-std=gnu++17',
477469
'-fPIC',
478470
'-fvisibility=hidden',
479471
'-fvisibility-inlines-hidden',

deps/LIEF/src/COFF/Section.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ std::string Section::to_string() const {
122122
[] (const char c) { return format("{:02x}", c); });
123123

124124
os << format("{:{}} {} ({})\n", "Name:", WIDTH, name(),
125-
join(fullname_hex, " "));
125+
fmt::to_string(join(fullname_hex, " ")));
126126

127127
os << format("{:{}} 0x{:x}\n", "Virtual Size", WIDTH, virtual_size())
128128
<< format("{:{}} 0x{:x}\n", "Virtual Address", WIDTH, virtual_address())
@@ -134,7 +134,7 @@ std::string Section::to_string() const {
134134
<< format("{:{}} 0x{:x}\n", "Pointer to line numbers", WIDTH, pointerto_line_numbers())
135135
<< format("{:{}} 0x{:x}\n", "Number of relocations", WIDTH, numberof_relocations())
136136
<< format("{:{}} 0x{:x}\n", "Number of lines", WIDTH, numberof_line_numbers())
137-
<< format("{:{}} {}", "Characteristics", WIDTH, join(list_str, ", "));
137+
<< format("{:{}} {}", "Characteristics", WIDTH, fmt::to_string(join(list_str, ", ")));
138138

139139
return os.str();
140140

deps/LIEF/src/MachO/layout_check.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class LayoutChecker {
8686

8787
template <typename... Args>
8888
bool error(const char *fmt, const Args &... args) {
89-
error_msg = fmt::format(fmt, args...);
89+
error_msg = fmt::vformat(fmt, fmt::make_format_args(args...));
9090
return false;
9191
}
9292

deps/LIEF/src/PE/LoadConfigurations/LoadConfiguration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ std::string LoadConfiguration::to_string() const {
917917

918918
if (auto val = guard_flags(); val && *val != 0) {
919919
oss << format("{:{}} {}\n", "Guard Flags:", WIDTH,
920-
fmt::join(guard_cf_flags_list(), ","));
920+
fmt::to_string(fmt::join(guard_cf_flags_list(), ",")));
921921
}
922922

923923
if (const CodeIntegrity* CI = code_integrity()) {

deps/LIEF/src/PE/Section.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ std::ostream& operator<<(std::ostream& os, const Section& section) {
142142

143143
if (const COFF::String* coff_str = section.coff_string()) {
144144
os << format("{:{}} {} ({}, {})\n", "Name:", WIDTH, section.name(),
145-
join(fullname_hex, " "), coff_str->str());
145+
fmt::to_string(join(fullname_hex, " ")), coff_str->str());
146146
} else {
147147
os << format("{:{}} {} ({})\n", "Name:", WIDTH, section.name(),
148-
join(fullname_hex, " "));
148+
fmt::to_string(join(fullname_hex, " ")));
149149
}
150150

151151
os << format("{:{}} 0x{:x}\n", "Virtual Size", WIDTH, section.virtual_size())
@@ -160,7 +160,7 @@ std::ostream& operator<<(std::ostream& os, const Section& section) {
160160
<< format("{:{}} 0x{:x}\n", "Pointer to line numbers", WIDTH, section.pointerto_line_numbers())
161161
<< format("{:{}} 0x{:x}\n", "Number of relocations", WIDTH, section.numberof_relocations())
162162
<< format("{:{}} 0x{:x}\n", "Number of lines", WIDTH, section.numberof_line_numbers())
163-
<< format("{:{}} {}", "Characteristics", WIDTH, join(list_str, ", "));
163+
<< format("{:{}} {}", "Characteristics", WIDTH, fmt::to_string(join(list_str, ", ")));
164164
return os;
165165
}
166166

deps/LIEF/src/PE/debug/ExDllCharacteristics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ std::string ExDllCharacteristics::to_string() const {
5959
std::ostringstream os;
6060
using namespace fmt;
6161
os << Debug::to_string() << '\n'
62-
<< format(" Characteristics: {}", join(characteristics_list(), ", "));
62+
<< format(" Characteristics: {}", fmt::to_string(join(characteristics_list(), ", ")));
6363
return os.str();
6464
}
6565

deps/LIEF/src/PE/layout_check.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class LayoutChecker {
106106

107107
template <typename... Args>
108108
bool error(const char *fmt, const Args &... args) {
109-
error_msg = fmt::format(fmt, args...);
109+
error_msg = fmt::vformat(fmt, fmt::make_format_args(args...));
110110
return false;
111111
}
112112

0 commit comments

Comments
 (0)