Fwd: tallocStatic: ld: attempted static link of dynamic object

Milan Hauth milahu at gmail.com
Mon Apr 28 07:11:10 UTC 2025


building a static talloc 2.4.3 fails with waf 2.1.5

```
$ nix-build '<nixpkgs>' -A pkgsStatic.talloc
...
       > Checking simple C program                : not found
       > The configuration failed
       > (complete log in /build/talloc-2.4.3/bin/config.log)
```

configurePhase runs

```
buildtools/bin/waf
--prefix=/tmp/nixbd/lf0wk88bkh3zw9f0ggv0ks26zkw0l51k-talloc-static-x86_64-unknown-linux-musl-2.4.3
--enable-talloc-compat1 --bundled-libraries=NONE
--builtin-libraries=replace --cross-compile
--cross-execute=/nix/store/al8bd0vx45iv2qb6ndxgik7cfl6dy0xf-exec/bin/exec
configure
```

config.log

```
$ cat /tmp/tmp.237HjvYNQ7/talloc-2.4.3/bin/config.log
...
Checking simple C program
==>
#define SRCDIR "/tmp/tmp.237HjvYNQ7/talloc-2.4.3"
#define HAVE_SYS_UTSNAME_H 1
/* #undef SYSTEM_UNAME_SYSNAME */
/* #undef SYSTEM_UNAME_MACHINE */
/* #undef SYSTEM_UNAME_RELEASE */
/* #undef SYSTEM_UNAME_VERSION */
#define HAVE_STDIO_H 1
#include <stdio.h>
 int main(void) { printf("hello world"); return 0; }
<==
[1/2] Compiling bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/test.c
['x86_64-unknown-linux-musl-gcc', '-MMD',
'-I/tmp/tmp.237HjvYNQ7/talloc-2.4.3/buildtools/wafsamba', '-I.',
'-I../..', '-I.', '-I../..', '../../test.c', '-c',
'-o/tmp/tmp.237HjvYNQ7/talloc-2.4.3/bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/testbuild/default/test.c.1.o']
[2/2] Linking bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/testbuild/default/testprog
['x86_64-unknown-linux-musl-gcc', 'test.c.1.o',
'-o/tmp/tmp.237HjvYNQ7/talloc-2.4.3/bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/testbuild/default/testprog',
'-Wl,-Bstatic', '-Wl,-Bdynamic']
err: /nix/store/d57vggzgdwhq8xpll7sxa8561rpkc6an-x86_64-unknown-linux-musl-binutils-2.44/bin/x86_64-unknown-linux-musl-ld:
attempted static link of dynamic object
`/nix/store/y75kpl0ypw5gpd98apzdcxizn1gs3pjk-musl-static-x86_64-unknown-linux-musl-1.2.5/lib/libc.so'
collect2: error: ld returned 1 exit status
```

gcc

```
mkdir -p bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/testbuild/default
cat >bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/test.c <<EOF
#define SRCDIR "$NIX_BUILD_TOP/$sourceRoot"
#define HAVE_SYS_UTSNAME_H 1
/* #undef SYSTEM_UNAME_SYSNAME */
/* #undef SYSTEM_UNAME_MACHINE */
/* #undef SYSTEM_UNAME_RELEASE */
/* #undef SYSTEM_UNAME_VERSION */
#define HAVE_STDIO_H 1
#include <stdio.h>
 int main(void) { printf("hello world"); return 0; }
EOF
pushd bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/testbuild/default
# compile
x86_64-unknown-linux-musl-gcc -MMD
-I$NIX_BUILD_TOP/$sourceRoot/buildtools/wafsamba -I. -I../.. -I.
-I../.. ../../test.c -c
-o$NIX_BUILD_TOP/$sourceRoot/bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/testbuild/default/test.c.1.o
# link
x86_64-unknown-linux-musl-gcc test.c.1.o
-o$NIX_BUILD_TOP/$sourceRoot/bin/.conf_check_f842c8fd62dc26d84809f47fc0f40da7/testbuild/default/testprog
-Wl,-Bstatic -Wl,-Bdynamic
popd
```

problem: the link step has `-Wl,-Bstatic -Wl,-Bdynamic`
it works when i remove `-Wl,-Bdynamic`

see also
https://gitlab.com/ita1024/waf/-/issues/2467



More information about the samba-technical mailing list