-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Linker eating functions in JSMESS again #2619
Comments
I can't seem to download that file (eta 19 hours right now), any chance you can put it up somewhere else? |
Oh wait, I got it. |
The issue is Swapping their order doesn't fix it, I assume because there is some other symbol dependency between those two, in the other direction. This should be solvable using some combination of linker flags, (group options?), but I'm not very familiar with those. (Btw, what is the A more general solution is to just not use |
That's the same linking order used by native builds though, is the thing.... -s is coming from https://github.com/startaq/mame/blob/master/makefile#L648 |
So I tried adding --start-group and --end-group around everything and the behaviour is the same, which strikes me as a bug. Putting libbus.a before and after liboptional.a does work though. |
I can't understand how that can work natively, because as I said, one .a needs a symbol from another .a and they are in the wrong order for that. Either the native linker has a bug, or my understanding of .a linking is incorrect, I guess. |
I'm not actually sure whether this exact case works on native as the native build is normally for all systems and not just one. If groups would work that would probably be enough for now though. |
Groups has one open issue on it, #2568, perhaps you are hitting that. |
If we can confirm it's that, we should close this and prioritize that other one. |
|
It does sound like #2568 is the same issue, yes. |
Ok, that other issue is now resolved on incoming, please check if groups works for you on that. |
Still doesn't seem to work. |
Even with groups? Then I guess we have another groups-related bug then. |
Looks to me like it works ok with groups,
Perhaps you had a typo in the groups command? Make sure the comma is present in |
It works if you do -Wl,--start-group but not with just --start-group etc. It would be nice if that wasn't a silent failure but I can work with this now. |
It will be tricky to add a warning, as we would need to add new code to track all arguments back to their source, to let us know which are in fact user-supplied args we are passing to clang, and which are not. Then, when we don't run clang (like here, when we just link bitcode to bitcode), we could warn. This would be nice to have, but a major refactoring like that is risky for new bugs. |
See emscripten-core/emscripten#2619 for discussion
I can't find an easy way to improve that warning. Closing this as the main issue is working as intended. |
See emscripten-core/emscripten#2619 for discussion git-svn-id: svn://dspnet.fr/mame/trunk@31513 749742ba-7341-0410-aadc-df50b521781e
See emscripten-core/emscripten#2619 for discussion
See emscripten-core/emscripten#2619 for discussion
This is happening again with current emscripten incoming, with slightly different symptoms:
I've uploaded the object files to http://interbutt.com/temp/linkerbug3.zip
Not sure what the significance is of the same symbol being listed as both U and T. |
I get an error trying to extract that archive - can you please re-upload it? |
There's nothing wrong with it as far as I can tell, but recompressed and reuploaded anyway. |
Ok, I can download it and extract it now. The command you quoted doesn't work out of the box - first, I had to fix up all the paths to point to the current dir. Not sure if that changes things or not. Second, 3 of the files ending in |
Look at the second code block in the post, I already massaged the command line to have everything in the current dir and rename the jaguar.o files to unique names. |
Thanks, I see now. |
@kripken Yes, I can confirm this is working using native Or should this be classified as an undefined behaviour? |
I honestly don't know what is defined and undefined behavior for
So only the basename is retained, and files are dumped in the current dir, so ones with identical basenames trample previous ones. Are you on mac? Perhaps mac We could work around this issue if we could extract files by their index number, and not by name. But I don't see an option for that on |
Definitely the issue with MESS:
|
Thanks, good to know that the simpler testcase helped us to at least know what the problem is now. Although, given that |
For the native
Please ignore the So this still looks like a bug of And yes, I'm on a mac, but I can confirm the same behaviour occurs on Linux(tested on a Linode VM). In mruby's case, the problem will be gone if we avoid using |
But if you extract a single file, using the basename (which is all there is at this point), then you can only extract one of the two? How can you specify the other? |
I don't have an answer for that, sorry, Google tells us that maybe we have to use more trickier way, so it makes me wonder if this should be categorized as "undefined behavior" rather than "bug". |
Based on that, it seems like |
Well, here's the complete build steps of mruby on a native platform: https://gist.github.com/xxuejie/915269285747b66a796b Basically what it does is the following 3 steps:
I guess the case here is that |
Ah, ok, so it sounds like |
If |
Yes, the only option is to write our own code to extract files from archives, I suppose. Perhaps like the link you posted above, I didn't take a close look yet though. |
@sunfishcode noticed the http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130708/180847.html
So this was intentionally removed from llvm-ar, and I'm fairly sure there's no point in filing a bug to ask for it to be re-implemented. So LLVM is not going to help us here. The only solution seems to be to write a new archive file parser. If someone can find a nice standalone one, that seems like a possibility. Writing one from scratch sounds like a bad idea - we'd need to debug it on multiple platforms, etc. etc. |
I can't find a workaround here. Deleting entries from a I pushed a test to verify that we issue a proper warning on this. As the workaround is fairly simple once the problem is known - rename a few source files, as mentioned in the warning text - I think that's the best we can do here. |
Thanks for the help! Webruby now works by ignoring the |
There ended up being too many affected files in MESS for renaming to be a good workaround so I used some makefile tricks to use .bc files instead of .a: mamedev/mame@31bc7f4 |
I ran into this issue only with emscripten toolchain. Can't you fix it by adding random numbers at the end of filename that goes into archive? Does it really matter what name is inside archive? |
Well, if the user inserts |
Another idea is that once you start extracting those files get their hash, and then use hash to identify identical files, not by name. I have case where files have identical name but their content is completely different. I assume you want to remove redundant content when linking and you're using name to identify that which causes this issue. |
The problem is that llvm-ar can only extract one file out of all the files with identical basenames in the archive. The only way to fix it would be to modify llvm-ar, however it already had such an option and they removed it, so I'm not sure they would even be interested. |
Ah ok, |
It is possible to extract individual files by name, and on native ar's except for OS X, apparently even when there is an identical basename. It's possible no one uses this functionality, though. Making the names unique isn't trivial though - should the same full path lead to the same unique name? or not? I'm not sure. Regardless, if this would be a useful option for people, I'm not opposed. But it would need to be an option and not the default behavior, I think. |
I can pack foo/bar.o and bar/bar.o into the same library and not have any issues linking on any platform other than Emscripten. Solution like foo_bar.o, bar_bar.o would be acceptable too. |
Let's move discussion to #2142 which is still open and focused on the last issue here. I'll give an update in there. |
Compare #131 (comment)
Getting a bunch of warnings about unresolved symbols when compiling JSMESS for the Tandy 1000 with current Emscripten incoming:
The pthread and SDL stuff is expected but the centronics functions seem to be getting munched by the linker - they are compiled into libbus.a but not the final binary.
To reproduce, use the following files: http://interbutt.com/temp/tandylinkerbug.zip
The text was updated successfully, but these errors were encountered: