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

wasm-ld: error: duplicate symbol: stderr #22629

Closed
fangyuan-neko opened this issue Sep 26, 2024 · 3 comments
Closed

wasm-ld: error: duplicate symbol: stderr #22629

fangyuan-neko opened this issue Sep 26, 2024 · 3 comments

Comments

@fangyuan-neko
Copy link

emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.67 (2c4461731b8c0bffbdecebc0030e0489712f9886)
clang version 20.0.0git (https:/github.com/llvm/llvm-project b9198a17315757dc0c2e831c9df0498dcab55285)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/fangyuan/.emsdk/upstream/bin

I get error message below:

fangyuan@fangyuan ~/D/gsl-2.8> emmake make
make: make
make  all-recursive
make[1]: Entering directory '/home/fangyuan/Downloads/gsl-2.8'
Making all in gsl
make[2]: Entering directory '/home/fangyuan/Downloads/gsl-2.8/gsl'
rm -f gsl*.h
HEADERLIST="../gsl*.h ../*/gsl*.h"; \
for h in $HEADERLIST; do \
  BASENAME=`basename $h`; \
  test -r $BASENAME || ln -s $h $BASENAME; \
done
...
libtool: link: ( cd ".libs" && rm -f "libgsl.la" && ln -s "../libgsl.la" "libgsl.la" )
/bin/sh ./libtool  --tag=CC   --mode=link /home/fangyuan/.emsdk/upstream/emscripten/emcc  -g -O2   -o gsl-randist gsl-randist.o libgsl.la cblas/libgslcblas.la -lm 
libtool: link: /home/fangyuan/.emsdk/upstream/emscripten/emcc -g -O2 -o .libs/gsl-randist gsl-randist.o  ./.libs/libgsl.so cblas/.libs/libgslcblas.so -lm -Wl,-rpath -Wl,/usr/local/lib
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]
wasm-ld: error: duplicate symbol: stderr
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: fiprintf
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: vfprintf
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: abort
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __errno_location
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __lockfile
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __unlockfile
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __stdio_close
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __stdio_exit
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __stderr_used
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __stdio_seek
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __stdio_write
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __towrite
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __towrite_needs_stdio_exit
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: fprintf
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: vfiprintf
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __small_fprintf
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __small_vfprintf
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: frexp
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: duplicate symbol: __fwritex
>>> defined in ./.libs/libgsl.so
>>> defined in cblas/.libs/libgslcblas.so

wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
emcc: error: '/home/fangyuan/.emsdk/upstream/bin/wasm-ld -o .libs/gsl-randist.wasm gsl-randist.o ./.libs/libgsl.so cblas/.libs/libgslcblas.so -L/home/fangyuan/.emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL-getprocaddr -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmpgjlwv0f3libemscripten_js_symbols.so --export=_emscripten_stack_alloc --export=__get_temp_ret --export=__set_temp_ret --export=__wasm_call_ctors --export=emscripten_stack_get_current --export=_emscripten_stack_restore --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-table -z stack-size=65536 --no-growable-memory --initial-heap=16777216 --no-entry --table-base=1 --global-base=1024' failed (returned 1)
make[2]: *** [Makefile:835: gsl-randist] Error 1
make[2]: Leaving directory '/home/fangyuan/Downloads/gsl-2.8'
make[1]: *** [Makefile:988: all-recursive] Error 1
make[1]: Leaving directory '/home/fangyuan/Downloads/gsl-2.8'
make: *** [Makefile:685: all] Error 2
emmake: error: 'make' failed (returned 2)
fangyuan@fangyuan ~/D/gsl-2.8 [1]> 

and I've also triedemmake make LDFLAGS=--all-static to avoid problem, but I failed

@sbc100
Copy link
Collaborator

sbc100 commented Sep 26, 2024

It looks like those shared libraries each contain copy of libc somehow.

The best fix here is to disable the use of shared libraries completely, since those .so files you have built are really just big object files.

To do this you can normally pass somehing like --disable-shared at configure time (assuming this an autoconf-based project).

I'm not sure what --all-static is but that is not a valid linker flag for emscripten or wasm-ld.

@fangyuan-neko
Copy link
Author

It looks like those shared libraries each contain copy of libc somehow.

The best fix here is to disable the use of shared libraries completely, since those .so files you have built are really just big object files.

To do this you can normally pass somehing like --disable-shared at configure time (assuming this an autoconf-based project).

I'm not sure what --all-static is but that is not a valid linker flag for emscripten or wasm-ld.

Think you, I add the paramteter to emconfigure ./configure --disable-shared, and it works!
P.S: I don't understand that why add paramteter --disable-shared to emmake make did not work.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 10, 2024

P.S: I don't understand that why add paramteter --disable-shared to emmake make did not work

--disable-shared is an configure argument, not a make argument, they are two separate phases that take different arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants