Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libredirect: Add support for Darwin #50246

Merged
merged 5 commits into from Nov 12, 2018
Merged

Conversation

aszlig
Copy link
Member

@aszlig aszlig commented Nov 11, 2018

The library can be used also on Darwin using it like this:

NIX_REDIRECTS='foo=bar' \
DYLD_INSERT_LIBRARIES=${libredirect}/lib/libredirect.so \
DYLD_FORCE_FLAT_NAMESPACE=1 \
some_program

So let's actually not hardcade gcc and add Darwin to meta.platforms.

No other changes seem to be required.

Cc: @zimbatm, @edolstra, @dezgeg, @copumpkin

The library can be used also on Darwin using it like this:

  NIX_REDIRECTS='foo=bar' \
  DYLD_INSERT_LIBRARIES=${libredirect}/lib/libredirect.so \
  DYLD_FORCE_FLAT_NAMESPACE=1 \
  some_program

So let's actually not hardcade gcc and add Darwin to meta.platforms.

No other changes seem to be required.

Signed-off-by: aszlig <aszlig@nix.build>
@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

building
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/ani97cssh4p7dniflksk889f4rvxdgis-libredirect-0
shrinking /nix/store/ani97cssh4p7dniflksk889f4rvxdgis-libredirect-0/lib/libredirect.so
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/ani97cssh4p7dniflksk889f4rvxdgis-libredirect-0/lib
patching script interpreter paths in /nix/store/ani97cssh4p7dniflksk889f4rvxdgis-libredirect-0
checking for references to /build in /nix/store/ani97cssh4p7dniflksk889f4rvxdgis-libredirect-0...
/nix/store/ani97cssh4p7dniflksk889f4rvxdgis-libredirect-0

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: libredirect

Partial log (click to expand)

/nix/store/l928iaj0m48lfb7dib6h7p22d50l566x-clang-wrapper-5.0.2/resource-root/include/stdarg.h:35:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
2 warnings generated.
installing
post-installation fixup
strip is /nix/store/g5r4apl0za012ffs6ladinwa5w0m1l3k-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/g2af9n36xcdrasdchqd5pd76bziiyl9r-libredirect-0/lib
patching script interpreter paths in /nix/store/g2af9n36xcdrasdchqd5pd76bziiyl9r-libredirect-0
/nix/store/g2af9n36xcdrasdchqd5pd76bziiyl9r-libredirect-0

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

building
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/h1z3mhdvxa44xb6nb7wygpxrgz6ci9hi-libredirect-0
shrinking /nix/store/h1z3mhdvxa44xb6nb7wygpxrgz6ci9hi-libredirect-0/lib/libredirect.so
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/h1z3mhdvxa44xb6nb7wygpxrgz6ci9hi-libredirect-0/lib
patching script interpreter paths in /nix/store/h1z3mhdvxa44xb6nb7wygpxrgz6ci9hi-libredirect-0
checking for references to /build in /nix/store/h1z3mhdvxa44xb6nb7wygpxrgz6ci9hi-libredirect-0...
/nix/store/h1z3mhdvxa44xb6nb7wygpxrgz6ci9hi-libredirect-0

@zimbatm
Copy link
Member

zimbatm commented Nov 11, 2018

@GrahamcOfBorg build libredirect

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

building
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/kqwp4p56pnrnpwq16rjcfsb4dfxc97g4-libredirect-0
shrinking /nix/store/kqwp4p56pnrnpwq16rjcfsb4dfxc97g4-libredirect-0/lib/libredirect.so
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/kqwp4p56pnrnpwq16rjcfsb4dfxc97g4-libredirect-0/lib
patching script interpreter paths in /nix/store/kqwp4p56pnrnpwq16rjcfsb4dfxc97g4-libredirect-0
checking for references to /build in /nix/store/kqwp4p56pnrnpwq16rjcfsb4dfxc97g4-libredirect-0...
/nix/store/kqwp4p56pnrnpwq16rjcfsb4dfxc97g4-libredirect-0

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: libredirect

Partial log (click to expand)

/nix/store/l928iaj0m48lfb7dib6h7p22d50l566x-clang-wrapper-5.0.2/resource-root/include/stdarg.h:35:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
2 warnings generated.
installing
post-installation fixup
strip is /nix/store/g5r4apl0za012ffs6ladinwa5w0m1l3k-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/zjv2hq60zi44r0f2bjlh6nm1216yfrmy-libredirect-0/lib
patching script interpreter paths in /nix/store/zjv2hq60zi44r0f2bjlh6nm1216yfrmy-libredirect-0
/nix/store/zjv2hq60zi44r0f2bjlh6nm1216yfrmy-libredirect-0

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

building
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0
shrinking /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0/lib/libredirect.so
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0/lib
patching script interpreter paths in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0
checking for references to /build in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0...
/nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

building
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0
shrinking /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0/lib/libredirect.so
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0/lib
patching script interpreter paths in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0
checking for references to /build in /nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0...
/nix/store/i0qwzfwxmbvn85i63yj5ml8bcv72lcll-libredirect-0

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: libredirect

Partial log (click to expand)

/nix/store/l928iaj0m48lfb7dib6h7p22d50l566x-clang-wrapper-5.0.2/resource-root/include/stdarg.h:35:50: note: expanded from macro 'va_arg'
#define va_arg(ap, type)    __builtin_va_arg(ap, type)
                                                 ^~~~
2 warnings generated.
installing
post-installation fixup
strip is /nix/store/g5r4apl0za012ffs6ladinwa5w0m1l3k-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/zjv2hq60zi44r0f2bjlh6nm1216yfrmy-libredirect-0/lib
patching script interpreter paths in /nix/store/zjv2hq60zi44r0f2bjlh6nm1216yfrmy-libredirect-0
/nix/store/zjv2hq60zi44r0f2bjlh6nm1216yfrmy-libredirect-0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

/nix/store/kqwp4p56pnrnpwq16rjcfsb4dfxc97g4-libredirect-0

This is to make sure we get the correct shared library suffix of the
target platform. While for example on Darwin it would even work with the
hardcoded .so prefix it's IMHO a bit nicer to have the actual native
extension.

Signed-off-by: aszlig <aszlig@nix.build>
This is just a sanity check on whether the library correctly wraps the
syscalls and it's using the "true" executable for posix_spawn() and
execv().

The installCheckPhase is not executed if we are cross-compiling, so this
shouldn't break cross-compilation.

One thing I'm not actually sure is whether ${coreutils}/bin/true is
universally available on all the platforms, nor whether all the
functions we use in the test are available, but we can still fix that
after we've found out about that.

Signed-off-by: aszlig <aszlig@nix.build>
@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

'libredirect.so' -> '/nix/store/y0qqg5bv77lwzjz6cn14x0wpiv6lh8pm-libredirect-0/lib/libredirect.so'
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/y0qqg5bv77lwzjz6cn14x0wpiv6lh8pm-libredirect-0
shrinking /nix/store/y0qqg5bv77lwzjz6cn14x0wpiv6lh8pm-libredirect-0/lib/libredirect.so
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/y0qqg5bv77lwzjz6cn14x0wpiv6lh8pm-libredirect-0/lib
patching script interpreter paths in /nix/store/y0qqg5bv77lwzjz6cn14x0wpiv6lh8pm-libredirect-0
checking for references to /build in /nix/store/y0qqg5bv77lwzjz6cn14x0wpiv6lh8pm-libredirect-0...
running install tests
/nix/store/y0qqg5bv77lwzjz6cn14x0wpiv6lh8pm-libredirect-0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: libredirect

Partial log (click to expand)

'libredirect.so' -> '/nix/store/mx43z123cf2pa3g0pnpnjh8axi1lmq94-libredirect-0/lib/libredirect.so'
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/mx43z123cf2pa3g0pnpnjh8axi1lmq94-libredirect-0
shrinking /nix/store/mx43z123cf2pa3g0pnpnjh8axi1lmq94-libredirect-0/lib/libredirect.so
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/mx43z123cf2pa3g0pnpnjh8axi1lmq94-libredirect-0/lib
patching script interpreter paths in /nix/store/mx43z123cf2pa3g0pnpnjh8axi1lmq94-libredirect-0
checking for references to /build in /nix/store/mx43z123cf2pa3g0pnpnjh8axi1lmq94-libredirect-0...
running install tests
/nix/store/mx43z123cf2pa3g0pnpnjh8axi1lmq94-libredirect-0

@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: libredirect

Partial log (click to expand)

'libredirect.dylib' -> '/nix/store/qcbmwjzbdgghjnrl0z3ah38n5hiva176-libredirect-0/lib/libredirect.dylib'
post-installation fixup
strip is /nix/store/g5r4apl0za012ffs6ladinwa5w0m1l3k-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/qcbmwjzbdgghjnrl0z3ah38n5hiva176-libredirect-0/lib
patching script interpreter paths in /nix/store/qcbmwjzbdgghjnrl0z3ah38n5hiva176-libredirect-0
running install tests
Assertion failed: (stat(TESTPATH, &testsb) != -1), function main, file test.c, line 50.
/nix/store/8qai18dv0nqyw6s61g9p91n8684rnlg8-stdenv-darwin/setup: line 1305: 17906 Abort trap: 6           NIX_REDIRECTS="/foo/bar/test=/nix/store/acnfbicd84bnya2l2dq868b5l482qihw-coreutils-8.30/bin/true" DYLD_INSERT_LIBRARIES="$out/lib/libredirect$shlibext" DYLD_FORCE_FLAT_NAMESPACE=1 ./test
builder for '/nix/store/abn55bz07azlgx7i2bvbs4j1dgspnsi0-libredirect-0.drv' failed with exit code 134
error: build of '/nix/store/abn55bz07azlgx7i2bvbs4j1dgspnsi0-libredirect-0.drv' failed

@edolstra edolstra merged commit f7d5b76 into NixOS:master Nov 12, 2018
aszlig added a commit to aszlig/nixpkgs that referenced this pull request Nov 12, 2018
Pull request NixOS#50246 was merged a bit too quickly and it was supposed to
fix libredirect on Darwin. However it still fails on Darwin because I
was using ofborg to check Darwin builds as I don't have Apple hardware.

Providing a symbol for stat shouldn't hurt on GNU/Linux but might work
on Darwin, because it probably doesn't have __xstat*() but might have a
stat() symbol.

Signed-off-by: aszlig <aszlig@nix.build>
aszlig added a commit that referenced this pull request Nov 12, 2018
Pull request #50246 was merged a bit too quickly and it was supposed to
fix libredirect on Darwin. However it still failed on Darwin and this
was missed by the person merging the pull request.

The reason this was failing was that there is no __xstat* on Darwin.

So I'm adding a wrapper for stat() as well as it works on Darwin and it
still doesn't hurt on GNU/Linux.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @edolstra, @zimbatm
@zimbatm
Copy link
Member

zimbatm commented Nov 12, 2018

I am going to back-port this to 18.09 unless there are objections

@LnL7
Copy link
Member

LnL7 commented Nov 12, 2018

The install_name is wrong so the library won't be usable without patching stuff afterwards, on darwin something like this is needed to set it properly.

$CC ... -Wl,-install_name,$out/lib/libredirect$shlibext

zimbatm added a commit to zimbatm/nixpkgs that referenced this pull request Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants