Skip to content

Commit b7991c1

Browse files
authored
Fix build on GCC 15 (Comes with Fedora 42). (#8626)
* Fix Fedora 42 build. * Move extern forward declarations for initmod binary2cpp fields to actually the global :: namespace, instead of having them sit inside the Halide::(anonymous) namespace. Fixes issue on G++ 15.
1 parent bf9c55d commit b7991c1

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/LLVM_Runtime_Linker.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,34 @@ std::unique_ptr<llvm::Module> parse_bitcode_file(llvm::StringRef buf, llvm::LLVM
2727
return result;
2828
}
2929

30+
} // namespace
31+
} // namespace Halide
32+
3033
#define DECLARE_INITMOD(mod) \
3134
extern "C" unsigned char halide_internal_initmod_##mod[]; \
3235
extern "C" int halide_internal_initmod_##mod##_length; \
36+
namespace Halide { \
37+
namespace { \
3338
std::unique_ptr<llvm::Module> get_initmod_##mod(llvm::LLVMContext *context) { \
3439
llvm::StringRef sb = llvm::StringRef((const char *)halide_internal_initmod_##mod, \
3540
halide_internal_initmod_##mod##_length); \
3641
return parse_bitcode_file(sb, context, #mod); \
42+
} \
43+
} \
3744
}
3845

3946
#define DECLARE_NO_INITMOD(mod) \
47+
namespace Halide { \
48+
namespace { \
4049
[[maybe_unused]] std::unique_ptr<llvm::Module> get_initmod_##mod(llvm::LLVMContext *, bool = false, bool = false) { \
4150
user_error << "Halide was compiled without support for this target\n"; \
4251
return std::unique_ptr<llvm::Module>(); \
4352
} \
4453
[[maybe_unused]] std::unique_ptr<llvm::Module> get_initmod_##mod##_ll(llvm::LLVMContext *) { \
4554
user_error << "Halide was compiled without support for this target\n"; \
4655
return std::unique_ptr<llvm::Module>(); \
56+
} \
57+
} \
4758
}
4859

4960
#define DECLARE_CPP_INITMOD_LOOKUP_BITS(mod, bits) \
@@ -56,22 +67,30 @@ std::unique_ptr<llvm::Module> parse_bitcode_file(llvm::StringRef buf, llvm::LLVM
5667
} while (0)
5768

5869
#define DECLARE_CPP_INITMOD_LOOKUP(mod) \
70+
namespace Halide { \
71+
namespace { \
5972
std::unique_ptr<llvm::Module> get_initmod_##mod(llvm::LLVMContext *context, bool bits_64, bool debug) { \
6073
if (bits_64) { \
6174
DECLARE_CPP_INITMOD_LOOKUP_BITS(mod, 64); \
6275
} else { \
6376
DECLARE_CPP_INITMOD_LOOKUP_BITS(mod, 32); \
6477
} \
78+
} \
79+
} \
6580
}
6681

6782
#define DECLARE_CPP_INITMOD_LOOKUP_64(mod) \
83+
namespace Halide { \
84+
namespace { \
6885
std::unique_ptr<llvm::Module> get_initmod_##mod(llvm::LLVMContext *context, bool bits_64, bool debug) { \
6986
if (bits_64) { \
7087
DECLARE_CPP_INITMOD_LOOKUP_BITS(mod, 64); \
7188
} else { \
7289
internal_error << "No support for 32-bit initmod: " #mod; \
7390
return nullptr; /* appease warnings */ \
7491
} \
92+
} \
93+
} \
7594
}
7695

7796
#define DECLARE_CPP_INITMOD(mod) \
@@ -315,6 +334,9 @@ DECLARE_CPP_INITMOD(riscv_cpu_features)
315334
DECLARE_NO_INITMOD(riscv_cpu_features)
316335
#endif // WITH_RISCV
317336

337+
namespace Halide {
338+
namespace {
339+
318340
llvm::DataLayout get_data_layout_for_target(Target target) {
319341
if (target.arch == Target::X86) {
320342
if (target.bits == 32) {

src/LLVM_Runtime_Linker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Support for linking LLVM modules that comprise the runtime.
66
*/
77

8+
#include <cstdint>
89
#include <memory>
910
#include <string>
1011
#include <vector>

src/StmtToHTML.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
#include <filesystem>
2929
#endif
3030

31-
namespace Halide {
32-
namespace Internal {
33-
3431
extern "C" unsigned char halide_html_template_StmtToHTML_dependencies_html[];
3532
extern "C" unsigned char halide_html_template_StmtToHTML_css[];
3633
extern "C" unsigned char halide_html_template_StmtToHTML_js[];
3734

35+
namespace Halide {
36+
namespace Internal {
37+
3838
// Classes defined within this file
3939
class CostModel;
4040
class AssemblyInfo;

0 commit comments

Comments
 (0)