Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,25 @@ stdenv.mkDerivation {
##
## GCC libs for non-GCC support
##
+ optionalString useGccForLibs ''
+ optionalString useGccForLibs (''

''
# In theory we shouldn't need this, because we always set `useLLVM` on
# Darwin, and maybe also break down `useLLVM` into fine-grained use flags
# (libgcc vs compiler-rt, ld.lld vs legacy, libc++ vs libstdc++, etc.)
# since Darwin isn't `useLLVM` on all counts. (See
# https://clang.llvm.org/docs/Toolchain.html for all the axes one might
# break `useLLVM` into.)
#
# But, for now, we haven't doneo these things, so we use
# `targetPlatform.isLinux` as a proxy.
+ optionalString targetPlatform.isLinux ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is intended to have this on macOS?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS libcxx != null so it shouldn't. On the other hand it might be needed with libcxxClang and not have it.

We might need to also make cc-wrapper libgcc/compiler-rt aware (something we probably should do in general) to fix that case if it is indeed messed up for libcxxClang.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I was just asking if there is a libgcc based stdenv for macOS like their is a libcxx stdenv for Linux.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I don't think there is. If there was it probably would use --gcc-toolchain. (When build finally build all the GCC libraries in separate derivations, this will be much easier!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a gccStdenv, which doesn't seem to use libc++ from what I can tell. I'm not sure what the implications of this flag are or if the condition triggers however.

HARDENING: disabled flags: pie
HARDENING: Is active (not completely disabled with "all" flag)
HARDENING: enabling fortify
HARDENING: enabling stackprotector
HARDENING: enabling strictoverflow
HARDENING: enabling format
HARDENING: enabling pic
extra flags before to /nix/store/q8ar8q8f2h4sq5563pcn9dnv7a8n8gns-gcc-9.3.0/bin/g++:
  -O2
  -D_FORTIFY_SOURCE=2
  -fstack-protector-strong
  --param
  ssp-buffer-size=4
  -fno-strict-overflow
  -Wformat
  -Wformat-security
  -Werror=format-security
  -fPIC
  -Wl\,-sdk_version
  -Wl\,10.12
  -Wl\,-no_uuid
original flags to /nix/store/q8ar8q8f2h4sq5563pcn9dnv7a8n8gns-gcc-9.3.0/bin/g++:
  -o
  hello
  hello.cc
extra flags after to /nix/store/q8ar8q8f2h4sq5563pcn9dnv7a8n8gns-gcc-9.3.0/bin/g++:
  -B/nix/store/fikpi6kfpfywadbqnrn6ldwif2glqvii-gcc-9.3.0-lib/lib
  -B/nix/store/i09q4si3r6ad3iblrdjxfmvl8bks6amg-Libsystem-osx-10.12.6/lib/
  -idirafter
  /nix/store/i09q4si3r6ad3iblrdjxfmvl8bks6amg-Libsystem-osx-10.12.6/include
  -idirafter
  /nix/store/q8ar8q8f2h4sq5563pcn9dnv7a8n8gns-gcc-9.3.0/lib/gcc/x86_64-apple-darwin/9.3.0/include-fixed
  -B/nix/store/nsq53ag0qb8q8ljxdwfxnm3k4ssbwqcf-gcc-wrapper-9.3.0/bin/
  -isystem
  /nix/store/29sdvdbaj16kxgzhxj72pa1dn3vrf9bw-clang-7.1.0/include
  -isystem
  /nix/store/29sdvdbaj16kxgzhxj72pa1dn3vrf9bw-clang-7.1.0/include
  -L/nix/store/29sdvdbaj16kxgzhxj72pa1dn3vrf9bw-clang-7.1.0/lib
  -L/nix/store/3z5szay7ax2p102ysnx8sgq8d305mp06-clang-7.1.0-lib/lib
  -L/nix/store/29sdvdbaj16kxgzhxj72pa1dn3vrf9bw-clang-7.1.0/lib
  -L/nix/store/3z5szay7ax2p102ysnx8sgq8d305mp06-clang-7.1.0-lib/lib
  -L/nix/store/i09q4si3r6ad3iblrdjxfmvl8bks6amg-Libsystem-osx-10.12.6/lib
  -L/nix/store/fikpi6kfpfywadbqnrn6ldwif2glqvii-gcc-9.3.0-lib/lib

'' + ''
echo "-B${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-cflags
echo "-L${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-ldflags
echo "-L${gccForLibs.lib}/${targetPlatform.config}/lib" >> $out/nix-support/cc-ldflags
''
'')

##
## General libc support
Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/compilers/llvm/10/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ let
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {

Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/compilers/llvm/11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ let
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {

Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/compilers/llvm/5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {

Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/compilers/llvm/6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {

Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/compilers/llvm/7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {

Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/compilers/llvm/8/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {

Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/compilers/llvm/9/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {

Expand Down
2 changes: 0 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8853,8 +8853,6 @@ in
mkdir -p "$rsrc/lib"
ln -s "${cc}/lib" "$rsrc/include"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
};

Expand Down