You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: undefined exported symbol when symbols file contain unused symbols #21516
This should give the error:
emcc: error: undefined exported symbol: "_unused_symbol" [-Wundefined] [-Werror]
Expected:
hello.so should be compiled without any errors.
More information:
This bug is introduced in 3.1.52. With the commit 7e808f1
GCC does not generate error in such situation.
To demonstrate, if the symfile file were:
hello_world
unused_symbol
Running this in terminal would generate hello.so without any issues:
Is this error: "undefined exported symbol" introduced from 7e808f1
expected behavior or is it a bug? Many projects use only one symbol file
in whole project, and gcc seems to allow it.
I've not heard of --retain-symbols-file before. Is this a commonly used flag?
I would find it a little strange to say -sEXPORTED_SYMBOLS=foo when linking then allow foo to be undefined.. so I guess from my POV this is working as intended. Is the problem that you don't know the list of symbols that you expect to be defined in your side module? (i.e. you only have one big list that contains symbols from many different side modules).
It sounds like maybe you want something more like -sMAYBE_EXPORT_SYMBOLS. BTW, we do have -sERROR_ON_UNDEFINED_SYMOLS=0. I guess we could modify that setting that it applies to explicitly exported functions too. Would that work for you? i.e. -sEXPORTED_FUNCTIONS=@symfile -sERROR_ON_UNDEFINED_SYMOLS=0?
I would find it a little strange to say -sEXPORTED_SYMBOLS=foo when linking then allow foo to be undefined.. so I guess from my POV this is working as intended. Is the problem that you don't know the list of symbols that you expect to be defined in your side module? (i.e. you only have one big list that contains symbols from many different side modules).
It sounds like maybe you want something more like -sMAYBE_EXPORT_SYMBOLS. BTW, we do have -sERROR_ON_UNDEFINED_SYMOLS=0. I guess we could modify that setting that it applies to explicitly exported functions too. Would that work for you? i.e. -sEXPORTED_FUNCTIONS=@symfile -sERROR_ON_UNDEFINED_SYMOLS=0?
Thanks for the suggestion. I tried this. Here is the result:
I was experimenting a use case when user has the freedom to disable certain libraries
without changing the sym file. (I will elaborate more after I run some more tests).
I was experimenting a use case when user has the freedom to disable certain libraries without changing the sym file. (I will elaborate more after I run some more tests).
So, my exact reason to report this was experimenting with another bug. Where emcc seems to be not "seeing" an already included library. I had a reproducer ready for that bug.
But the reproducer was not working in the newer versions, which lead me to discover this one. So I filed this one instead.
Anyway, I was able to create a new reproducer for the other bug, bypassing this issue. So I will create a separate issue reporting that bug and mention it here.
Activity
sbc100 commentedon Mar 14, 2024
I've not heard of
--retain-symbols-filebefore. Is this a commonly used flag?I would find it a little strange to say
-sEXPORTED_SYMBOLS=foowhen linking then allowfooto be undefined.. so I guess from my POV this is working as intended. Is the problem that you don't know the list of symbols that you expect to be defined in your side module? (i.e. you only have one big list that contains symbols from many different side modules).It sounds like maybe you want something more like
-sMAYBE_EXPORT_SYMBOLS. BTW, we do have-sERROR_ON_UNDEFINED_SYMOLS=0. I guess we could modify that setting that it applies to explicitly exported functions too. Would that work for you? i.e.-sEXPORTED_FUNCTIONS=@symfile -sERROR_ON_UNDEFINED_SYMOLS=0?Labnann commentedon Mar 20, 2024
We can do it this way:
symfile_gcc.ver:
Then in terminal:
This executes without any issue.
Thanks for the suggestion. I tried this. Here is the result:
The error still exists :(
sbc100 commentedon Mar 20, 2024
Indeed, I was suggesting that we could extent
-sERROR_ON_UNDEFINED_SYMBOLS=0to apply to explicitly exported symbols too.However, I'm not really sure its a good idea.
Is there some reason that in your case you cannot be precise about that exact symbols you want to export from each shared library?
Labnann commentedon Mar 20, 2024
I am sorry, I tried both, got the same error and accidentally copy pasted result from the wrong output.
Here is the correct one:
I was experimenting a use case when user has the freedom to disable certain libraries
without changing the sym file. (I will elaborate more after I run some more tests).
Labnann commentedon Mar 31, 2024
By the way, it generates the .so file anyway. And it is usable.
Labnann commentedon Mar 31, 2024
So, my exact reason to report this was experimenting with another bug. Where emcc seems to be not "seeing" an already included library. I had a reproducer ready for that bug.
But the reproducer was not working in the newer versions, which lead me to discover this one. So I filed this one instead.
Anyway, I was able to create a new reproducer for the other bug, bypassing this issue. So I will create a separate issue reporting that bug and mention it here.