From 7ada53f004154b91a8c47708b782be3df048a24b Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Sun, 9 Jun 2024 08:42:25 -0400 Subject: [PATCH] split(libstdcxx) (#6373) * split(libstdcxx) * fix array syntax * -std=c++20 * fix test * Update package.yml * fix darwin test --- projects/gnu.org/gcc/libstdcxx/package.yml | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 projects/gnu.org/gcc/libstdcxx/package.yml diff --git a/projects/gnu.org/gcc/libstdcxx/package.yml b/projects/gnu.org/gcc/libstdcxx/package.yml new file mode 100644 index 00000000..a5ace307 --- /dev/null +++ b/projects/gnu.org/gcc/libstdcxx/package.yml @@ -0,0 +1,127 @@ +distributable: + url: https://ftp.gnu.org/gnu/gcc/gcc-{{version.raw}}/gcc-{{ version.raw }}.tar.xz + strip-components: 1 + +versions: + github: gcc-mirror/gcc/tags + strip: /^releases\/gcc-/ + +dependencies: + gnu.org/binutils: '*' # linker needs `as` + gnu.org/gmp: '>=4.2' + gnu.org/mpfr: '>=2.4.0' + gnu.org/mpc: '>=0.8.0' + +build: + dependencies: + linux: + gnu.org/gcc: '*' + gnu.org/make: '*' + perl.org: '^5.6.1' + gnu.org/patch: '*' + curl.se: '*' + github.com/westes/flex: '*' + working-directory: build + script: + # Applying ians patches on x86-64 too, since he sometimes gets fixes in faster, like: + # https://github.com/orgs/Homebrew/discussions/5216 + # If we have a patch, apply it + - run: | + if test -n "$PATCH{{version.major}}{{version.minor}}"; then + curl "$PATCH{{version.major}}{{version.minor}}" | patch -p1 + fi + if: darwin + working-directory: .. + + # if there's no diff yet, unpack iains' source over ours + - run: | + if test -n "$BRANCH{{version.major}}{{version.minor}}"; then + curl -L "$BRANCH{{version.major}}{{version.minor}}" | tar xz --strip-components=1 + fi + if: darwin + working-directory: .. + + # On Linux, we need to statically link libstdc++ and libgcc + - run: export ARGS=($ARGS --with-boot-ldflags="-static-libstdc++ -static-libgcc $LDFLAGS") + if: linux + - run: export ARGS=($ARGS) + if: darwin + + - ../configure "${ARGS[@]}" + - make --jobs {{ hw.concurrency }} + - make install-target-libstdc++-v3 install-target-libgcc + + # On Linux, we need to move the libraries to the lib directory. + - run: | + mv lib64/* lib/ + rmdir lib64 + if: linux + working-directory: ${{prefix}} + env: + # Branch from the Darwin maintainer of GCC, with a few generic fixes and + # Apple Silicon support, located at https://github.com/iains/gcc-12-branch + PATCH122: https://raw.githubusercontent.com/Homebrew/formula-patches/1d184289/gcc/gcc-12.2.0-arm.diff + # https://github.com/iains/gcc-darwin-arm64 + PATCH131: https://raw.githubusercontent.com/Homebrew/formula-patches/master/gcc/gcc-13.1.0.diff + BRANCH105: https://github.com/iains/gcc-10-branch/archive/refs/heads/gcc-10-5Dr0-pre-0.tar.gz + BRANCH114: https://github.com/iains/gcc-11-branch/archive/refs/tags/gcc-11.4-darwin-r0.tar.gz + BRANCH123: https://github.com/iains/gcc-12-branch/archive/refs/tags/gcc-12.3-darwin-r0.tar.gz + BRANCH132: https://github.com/iains/gcc-13-branch/archive/refs/heads/gcc-13-2-darwin.tar.gz + BRANCH133: https://github.com/iains/gcc-13-branch/archive/refs/heads/gcc-13-3-darwin-pre-0.tar.gz + BRANCH141: https://github.com/iains/gcc-14-branch/archive/refs/heads/gcc-14-1-darwin-pre-0.tar.gz + ARGS: + - --prefix={{ prefix }} + - --libdir={{ prefix }}/lib + - --disable-bootstrap + - --disable-nls + linux: + ARGS: + - --disable-multilib + - --enable-default-pie + - --enable-pie-tools + - --enable-host-pie + linux/x86-64: + LDFLAGS: $LDFLAGS -pie + CFLAGS: $CFLAGS -fPIC -fPIE + CXXFLAGS: $CXXFLAGS -fPIC -fPIE + darwin: + ARGS: + # Reliance on CLT hard path is yuck. + - --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk + darwin/aarch64: + ARGS: + # https://en.wikipedia.org/wiki/Darwin_(operating_system)#Darwin_16%E2%80%9319;_OS_X_rebranded_into_macOS + - --build=aarch64-apple-darwin20.0.0 + darwin/x86-64: + ARGS: + - --build=x86_64-apple-darwin20.0.0 + # llvm-as generates __compact_unwind sections, even when told not to. this causes build errors + # for ^10 on darwin+x86-64 + # https://stackoverflow.com/questions/52211390/trouble-building-gcc-on-mac-cant-find-system-headers + BOOT_CFLAGS: -Wa,-mmacos-version-min=10.5 + CFLAGS_FOR_TARGET: -Wa,-mmacos-version-min=10.5 + and CXXFLAGS_FOR_TARGET: -Wa,-mmacos-version-min=10.5 + +test: + dependencies: + gnu.org/gcc: '*' + script: + - run: g++ -o test $FIXTURE -std=c++20 -lstdc++ + fixture: + extname: cc + content: | + #include + struct exception { }; + int main() + { + std::cout << "Hello, world!" << std::endl; + try { throw exception{}; } + catch (exception) { } + catch (...) { } + return 0; + } + - test "$(./test)" = "Hello, world!" + - run: ldd test | grep "{{prefix}}/lib/libstdc++.so" + if: linux + - run: otool -L test | grep 'gnu.org/gcc/libstdcxx/.*/lib/libstdc++\..*\.dylib' + if: darwin