Skip to content

gcc7 libstdc++ on darwin fails to compile #73319

@hlolli

Description

@hlolli

Describe the bug
While compiling gcc7 (or gcc8) in a non-sandboxed darwin enironment (as a Linux user I'm still trying to wrap my head around the sandboxing on darwin), I get compilation failures.

/nix/store/z4rsz8dl3s9qlvbvs9wbfk5ahwfhqrli-bash-4.4-p23/bin/bash ../libtool --tag CXX --tag disable-shared   --mode=compile /private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/./gcc/xgcc -shared-libgcc -B/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/./gcc -nostdinc++ -L/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/src -L/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/src/.libs -L/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/libsupc++/.libs -O2 -I/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -B/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib/ -idirafter /nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -Wl,-rpath,/nix/store/bgpnnbyxjkipldxhiwyx9pd7pysf6qzj-gcc-8.3.0-lib/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-rpath -Wl,/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib    -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/gcc-8.3.0/libstdc++-v3/../libgcc -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/include/x86_64-apple-darwin -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/include -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/gcc-8.3.0/libstdc++-v3/libsupc++   -prefer-pic -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi  -fdiagnostics-show-location=once    -ffunction-sections -fdata-sections  -frandom-seed=del_opant.lo -O2 -I/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -B/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib/ -idirafter /nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -Wl,-rpath,/nix/store/bgpnnbyxjkipldxhiwyx9pd7pysf6qzj-gcc-8.3.0-lib/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-rpath -Wl,/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib  -std=gnu++1z -c ../../../../gcc-8.3.0/libstdc++-v3/libsupc++/del_opant.cc
In file included from /private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/include/stdlib.h:36,
                 from ../../../../gcc-8.3.0/libstdc++-v3/libsupc++/new_opa.cc:27:
/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/include/cstdlib:132:11: error: '::aligned_alloc' has not been declared
   using ::aligned_alloc;
           ^~~~~~~~~~~~~
/nix/store/z4rsz8dl3s9qlvbvs9wbfk5ahwfhqrli-bash-4.4-p23/bin/bash ../libtool --tag CXX --tag disable-shared   --mode=compile /private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/./gcc/xgcc -shared-libgcc -B/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/./gcc -nostdinc++ -L/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/src -L/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/src/.libs -L/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/libsupc++/.libs -O2 -I/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -B/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib/ -idirafter /nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -Wl,-rpath,/nix/store/bgpnnbyxjkipldxhiwyx9pd7pysf6qzj-gcc-8.3.0-lib/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-rpath -Wl,/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib    -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/gcc-8.3.0/libstdc++-v3/../libgcc -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/include/x86_64-apple-darwin -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/build/x86_64-apple-darwin/libstdc++-v3/include -I/private/var/folders/9k/hr12t49132lgnpzq88w_h6740000gn/T/nix-build-gcc-8.3.0.drv-0/gcc-8.3.0/libstdc++-v3/libsupc++   -prefer-pic -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi  -fdiagnostics-show-location=once    -ffunction-sections -fdata-sections  -frandom-seed=del_opva.lo -O2 -I/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -B/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib/ -idirafter /nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/include -Wl,-rpath,/nix/store/bgpnnbyxjkipldxhiwyx9pd7pysf6qzj-gcc-8.3.0-lib/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-rpath -Wl,/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib -Wl,-L/nix/store/b0wshq9a0b7x9kvw8ca0bhljgjp3vgyl-Libsystem-osx-10.12.6/lib  -std=gnu++1z -c ../../../../gcc-8.3.0/libstdc++-v3/libsupc++/del_opva.cc
../../../../gcc-8.3.0/libstdc++-v3/libsupc++/new_opa.cc:47:9: error: '::aligned_alloc' has not been declared
 using ::aligned_alloc;
         ^~~~~~~~~~~~~
../../../../gcc-8.3.0/libstdc++-v3/libsupc++/new_opa.cc: In function 'void* operator new(std::size_t, std::align_val_t)':
../../../../gcc-8.3.0/libstdc++-v3/libsupc++/new_opa.cc:128:20: error: '__gnu_cxx::aligned_alloc' has not been declared
   using __gnu_cxx::aligned_alloc;
                    ^~~~~~~~~~~~~
../../../../gcc-8.3.0/libstdc++-v3/libsupc++/new_opa.cc:129:33: error: 'aligned_alloc' was not declared in this scope
   while (__builtin_expect ((p = aligned_alloc (align, sz)) == 0, false))
                                 ^~~~~~~~~~~~~

To Reproduce

To reproduce this exactly like I did, is probably nonsense, since it will cause almost every package to recompile. Essentially this came after modification to libdispatch, where I added the following command at the end of the installPhase (I add here to rule out that these two may be connected).

# gcc compatability. Source: https://stackoverflow.com/a/28014302/3714556
    substituteInPlace $out/include/dispatch/object.h \
      --replace 'typedef void (^dispatch_block_t)(void);' \
                '#ifdef __clang__
                 typedef void (^dispatch_block_t)(void);
                 #else
                 typedef void* dispatch_block_t;
                 #endif'

Alternatively dummy modify nixpkgs/pkgs/development/compilers/gcc/7/default.nix and build nix-build . -A gcc7 on commit 6236cffa69757549207ad7d2001d96ac16ad1cdf or later.

Metadata

 - system: `"x86_64-darwin"`
 - host os: `Darwin 19.0.0, macOS 10.15`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.1`
 - channels(root): `"nixpkgs-20.03pre196811.7818f30cc4b"`
 - channels(hlolli): `"darwin, nixpkgs-20.03pre196811.7818f30cc4b"`
 - nixpkgs: `/Users/hlolli/.nix-defexpr/channels/nixpkgs`

ADDED: I can confirm that this bug has nothing to do with the change I did on libdispatch, since I reverted it and rebuilt, getting the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: darwinRunning or building packages on Darwin
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions