Hello,

I came across weird duplicate symbol errors while using functors and the
-static flag in CHICKEN 5.

You can find the full repro here in case my explanation is not clear:
https://github.com/antoine1fr/chicken-functor-static-error.

Given:

* a unit 'a',
* a unit 'make-b' that defines a functor 'make-b' and uses 'a',
* a unit 'b-foo' that creates the module 'b-foo' from 'make-b'.

The following link command:

  $ csc -v -static -o test ./a.o ./make-b.o ./b-foo.o ./test.o

generates the following call to the C compiler:

  'clang' 'test.o' 'b-foo.o' 'make-b.o' 'a.o' 'a.o' -o 'test' -m64 
-L/usr/local/Cellar/chicken/5.0.0/lib 
/usr/local/Cellar/chicken/5.0.0/lib/libchicken.a -lm

The problem is that 'a.o' is issued twice to clang. This results in
duplicate symbol errors.

Here are the full build logs:

  $ make
  csc -J -static -o a.o -c a.scm
  csc -J -static -o make-b.o -c make-b.scm
  csc -J -static -o b-foo.o -c b-foo.scm
  csc -J -static -o test.o -c test.scm
  csc -v -static -o test ./a.o ./make-b.o ./b-foo.o ./test.o
  'clang' 'test.o' 'b-foo.o' 'make-b.o' 'a.o' 'a.o' -o 'test' -m64 
-L/usr/local/Cellar/chicken/5.0.0/lib 
/usr/local/Cellar/chicken/5.0.0/lib/libchicken.a -lm
  duplicate symbol _C_a_toplevel in:
      a.o
  ld: 1 duplicate symbol for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
  
  Error: shell command terminated with non-zero exit status 256: 'clang' 
'test.o' 'b-foo.o' 'make-b.o' 'a.o' 'a.o' -o 'test' -m64 
-L/usr/local/Cellar/chicken/5.0.0/lib 
/usr/local/Cellar/chicken/5.0.0/lib/libchicken.a -lm
  make: *** [test] Error 1

Can someone tell me what I'm doing wrong?

Best,
Antoine


_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to