Skip to content

Commit 62a1550

Browse files
committed
Pass compiler flags as scons variables for configure checks
Root cause: scons runs its own compiler checks (like "Checking for C++ header file cmath...") using a test compile. These checks weren't picking up the CFLAGS/CXXFLAGS we set in ENV because scons doesn't automatically use environment variables for its test compiles. Solution: 1. Set CPPFLAGS in ENV to include SDK libc++ header path (-I...) 2. Pass CXXFLAGS, CCFLAGS, and CPPFLAGS as scons command-line variables This ensures scons' configuration test compiles use the correct flags and can find standard C++ headers like <cmath> in the SDK.
1 parent 82cd3f4 commit 62a1550

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packaging/homebrew/mfc.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,18 @@ def install
4949
ENV["CXXFLAGS"] = "-isysroot#{sdk_path} -stdlib=libc++"
5050
ENV["SDKROOT"] = sdk_path.to_s
5151

52-
# Run scons, explicitly telling it which compilers to use
53-
# Add SDK C++ include path to extra_inc_dirs so scons can find standard headers
52+
# Also set include path variables for libc++ headers
5453
cxx_inc_path = "#{sdk_path}/usr/include/c++/v1"
54+
ENV["CPPFLAGS"] = ["-I#{cxx_inc_path}", ENV.fetch("CPPFLAGS", nil)].compact.join(" ")
55+
56+
# Run scons, explicitly passing compiler flags as scons variables
57+
# This ensures they apply to scons' configuration test compiles
5558
system venv/"bin/python", "-m", "SCons", "build",
5659
"CC=#{ENV.cc}",
5760
"CXX=#{ENV.cxx}",
61+
"CXXFLAGS=#{ENV["CXXFLAGS"]}",
62+
"CCFLAGS=#{ENV["CFLAGS"]}",
63+
"CPPFLAGS=#{ENV["CPPFLAGS"]}",
5864
"python_package=y",
5965
"f90_interface=n",
6066
"system_sundials=y",

0 commit comments

Comments
 (0)