Skip to content

Commit e3310b7

Browse files
committed
[Povray] Work around build failure due to target OS macros changes.
llvm/llvm-project#74676 changes some predefined target OS macros on Apple platforms, which breaks building both Blender and Povray. Work around build failures by adding -fno-define-target-os-macros if available. (Workaround has already been applied to SPEC2017's version of Povray in 9b14a92)
1 parent bc9b4c1 commit e3310b7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

External/Povray/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ if(TEST_SUITE_POVRAY_ROOT)
1212
${TEST_SUITE_POVRAY_ROOT}/source/libpng/example.c
1313
)
1414

15+
if(APPLE)
16+
# Building Povray breaks with -fdefine-target-os-macros, add flag to disable
17+
# it as workaround.
18+
include(CheckCCompilerFlag)
19+
check_c_compiler_flag(-fno-define-target-os-macros
20+
COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
21+
if (COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
22+
list(APPEND CPPFLAGS
23+
-fno-define-target-os-macros
24+
)
25+
endif()
26+
endif()
27+
1528
list(APPEND CPPFLAGS
1629
-I${TEST_SUITE_POVRAY_ROOT}/source
1730
-I${TEST_SUITE_POVRAY_ROOT}/source/unix

External/SPEC/CFP2006/453.povray/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ if(ARCH STREQUAL "AArch64" OR ARCH STREQUAL "LoongArch")
99
list(APPEND CXXFLAGS -ffp-contract=off)
1010
endif()
1111

12+
if(APPLE)
13+
# Building Povray breaks with -fdefine-target-os-macros, add flag to disable
14+
# it as workaround.
15+
include(CheckCCompilerFlag)
16+
check_c_compiler_flag(-fno-define-target-os-macros
17+
COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
18+
if (COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
19+
add_compile_options(-fno-define-target-os-macros)
20+
endif()
21+
endif()
22+
1223
macro(test_input run_type stdout_reltol)
1324
llvm_test_run(RUN_TYPE ${run_type}
1425
WORKDIR %S/data/${run_type}/input

0 commit comments

Comments
 (0)