Skip to content

Commit ec4c48d

Browse files
authored
cling: fix build on macOS (#415831)
2 parents 67adad2 + ca646c4 commit ec4c48d

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

pkgs/by-name/cl/cling/package.nix

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
apple-sdk,
23
cmake,
34
fetchFromGitHub,
45
git,
@@ -10,7 +11,7 @@
1011
python3,
1112
zlib,
1213

13-
# *NOT* from LLVM 9!
14+
# *NOT* from LLVM 13!
1415
# The compiler used to compile Cling may affect the runtime include and lib
1516
# directories it expects to be run with. Cling builds against (a fork of) Clang,
1617
# so we prefer to use Clang as the compiler as well for consistency.
@@ -131,25 +132,6 @@ let
131132
};
132133
};
133134

134-
# Runtime flags for the C++ standard library
135-
cxxFlags =
136-
if useLLVMLibcxx then
137-
[
138-
"-I"
139-
"${lib.getDev llvmPackages_13.libcxx}/include/c++/v1"
140-
"-L"
141-
"${llvmPackages_13.libcxx}/lib"
142-
"-l"
143-
"${llvmPackages_13.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}"
144-
]
145-
else
146-
[
147-
"-I"
148-
"${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}"
149-
"-I"
150-
"${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}/${stdenv.hostPlatform.config}"
151-
];
152-
153135
# The flags passed to the wrapped cling should
154136
# a) prevent it from searching for system include files and libs, and
155137
# b) provide it with the include files and libs it needs (C and C++ standard library plus
@@ -172,15 +154,35 @@ let
172154
"-isystem"
173155
"${lib.getLib unwrapped}/lib/clang/${llvmPackages_13.clang.version}/include"
174156
]
175-
++ cxxFlags
157+
++ lib.optionals useLLVMLibcxx [
158+
"-I"
159+
"${lib.getDev llvmPackages_13.libcxx}/include/c++/v1"
160+
"-L"
161+
"${llvmPackages_13.libcxx}/lib"
162+
"-l"
163+
"${llvmPackages_13.libcxx}/lib/libc++${stdenv.hostPlatform.extensions.sharedLibrary}"
164+
]
165+
++ lib.optionals (!useLLVMLibcxx) [
166+
"-I"
167+
"${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}"
168+
"-I"
169+
"${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}/${stdenv.hostPlatform.config}"
170+
]
176171
++ [
177-
# System libc
172+
# System libc on Linux
173+
# On Darwin, this is an empty directory, so we need a separate include with
174+
# apple-sdk (see below)
178175
"-isystem"
179176
"${lib.getDev stdenv.cc.libc}/include"
180177

181178
# cling includes
182179
"-isystem"
183180
"${lib.getDev unwrapped}/include"
181+
]
182+
++ lib.optionals stdenv.hostPlatform.isDarwin [
183+
# On Darwin, we need the system includes
184+
"-isystem"
185+
"${apple-sdk}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
184186
];
185187

186188
in

0 commit comments

Comments
 (0)