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

Duplicate symbol when using no arguments version of main with lto #137

Closed
caspervonb opened this issue Nov 19, 2019 · 3 comments · Fixed by #138
Closed

Duplicate symbol when using no arguments version of main with lto #137

caspervonb opened this issue Nov 19, 2019 · 3 comments · Fixed by #138

Comments

@caspervonb
Copy link

caspervonb commented Nov 19, 2019

The linker is fussing about duplicate symbol __original_main when trying to use main with the signature int main(void)

Related #112

@caspervonb caspervonb changed the title Duplicate symbol __original_main when using main(void) Duplicate symbol when using no arguments version of main Nov 19, 2019
@sunfishcode
Copy link
Member

Thanks for the report! I'm unfortunately not able to reproduce this. Would you mind posting more information, such as your full test case, the platform you're on, and the command-line arguments you're compiling and linking with?

@caspervonb
Copy link
Author

The test program was just a bare-bones main.

int main(void) {
  return 0;
}

But it seems that link time optimisations is the culprit, the following fails

/opt/wasi-sdk-8.0/bin/clang --target=wasm32-wasi --sysroot=/opt/wasi-sdk-8.0/share/wasi-sysroot -flto  -o obj/main.o -c src/main.c

/opt/wasi-sdk-8.0/bin/clang --target=wasm32-wasi --sysroot=/opt/wasi-sdk-8.0/share/wasi-sysroot -flto  -o main.wasm obj/main.o
wasm-ld: error: duplicate symbol: __original_main

But if i remove -flto it works fine.

/opt/wasi-sdk-8.0/bin/clang --target=wasm32-wasi --sysroot=/opt/wasi-sdk-8.0/share/wasi-sysroot -o obj/main.o -c src/main.c
/opt/wasi-sdk-8.0/bin/clang --target=wasm32-wasi --sysroot=/opt/wasi-sdk-8.0/share/wasi-sysroot -o main.wasm obj/main.o

@caspervonb caspervonb changed the title Duplicate symbol when using no arguments version of main Duplicate symbol when using no arguments version of main with lto Nov 20, 2019
@sunfishcode
Copy link
Member

Thanks! I've now submitted #138 with a fix.

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

Successfully merging a pull request may close this issue.

2 participants