netbsd.compat: fix libs by using cctools strip as objcopy

Reverts d43df749ac

NetBSD makefiles strip local symbols from libs using `OBJCOPY?=objcopy`,
which is missing on macOS. GNU objcopy appears to succeed but produces
broken .a libs which do not link into dependers.

(As this issue does not fail the netbsd.compat build,
downstream netbsd.install is added to passthru.tests.)

Since `OBJCOPY` is only used for stripping, we can:
* skip stripping with the hacky `OBJCOPY=echo`
* use cctools strip, which is invoked in the same way

The latter is obviously preferable if it works.
Indeed, locals are stripped, although it doesn't affect size much.
Comparison:

`OBJCOPY=echo`:
```
$ du -b result/lib/*.a
347784	result/lib/libnbcompat.a
357120	result/lib/libnbcompat_p.a
```

`OBJCOPY=${cctools}/bin/strip`:
```
$ du -b result/lib/*.a
347008	result/lib/libnbcompat.a
357120	result/lib/libnbcompat_p.a
```
This commit is contained in:
Ryan Burns 2021-09-22 17:42:12 -07:00
parent d43df749ac
commit 9eb591df10

View File

@ -188,8 +188,6 @@ in lib.makeScopeWithSplicing
bsdSetupHook netbsdSetupHook
makeMinimal
rsync
] ++ lib.optionals stdenv.buildPlatform.isDarwin [
buildPackages.binutils
];
buildInputs = with self; commonDeps;
@ -204,9 +202,15 @@ in lib.makeScopeWithSplicing
"TSORT=cat"
# Can't process man pages yet
"MKSHARE=no"
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
# GNU objcopy produces broken .a libs which won't link into dependers.
# Makefiles only invoke `$OBJCOPY -x/-X`, so cctools strip works here.
"OBJCOPY=${buildPackages.darwin.cctools}/bin/strip"
];
RENAME = "-D";
passthru.tests = { netbsd-install = self.install; };
patches = [
./compat-cxx-safe-header.patch
./compat-dont-configure-twice.patch