Pass -c when compiling SDL2 object files#9511
Conversation
Without `-c` emscripten will try to run lld on the object files its given to produce another object file. We should probably disable that for the single build case. This breakage was introduced in #9444 and we should probably address it, but compiling without `-c` is also broken so fixing here. Fixes #9510
That surprises me - I didn't realize that was happening when looking at the recent linking PRs. I think we should fix that directly, i.e., I realize it's a little odd that emscripten looks at the suffix of the output file to know what to emit, and I'm open to finding a path to changing that, but we need to think carefully about how to do that without breaking users. |
|
Alternatively, maybe we should make |
kripken
left a comment
There was a problem hiding this comment.
Regardless of the linking regression fix this PR looks good.
I agree and I will restore the behavior. Its a little more subtle than one might imagine though. The old behaviour had a special case for a single object file:
The new behaviour is that it run lld in all cases, even on a single object file. This means that if you pass certain flags such as The SDL build script was missing the I'm happy to temporarily restore the previous behaviour. However, in the long run I think we can do a bit better. I don't think either of the above use cases is useful or worth maintaining. There is a use case for linking object into a single object, but I think its rare and we should only allow it when all the input files are also objects. So passing a source file with output as an object file without |
Rather than run the linker, simply copy the object file to the output. This restores the previously behaviour. In the future we probably want to put this behavior behind a flag as link objects together should be explicit. See #9511
Rather than run the linker, simply copy the object file to the output. This restores the previously behaviour. In the future we probably want to put this behavior behind a flag as link objects together should be explicit. See #9511
Without `-c` emscripten will try to run lld on the object files its given to produce another object file. We should probably disable that for the single build case. This breakage was introduced in emscripten-core#9444 and we should probably address it, but compiling without `-c` is also broken so fixing here. Fixes emscripten-core#9510
…core#9548) Rather than run the linker, simply copy the object file to the output. This restores the previously behaviour. In the future we probably want to put this behavior behind a flag as link objects together should be explicit. See: emscripten-core#9511 Fixes: emscripten-core#9571
Remove the optimization (again) for the special case of single object input, which skips the linker and directly copies the input object file to output. This behavior interferes with linking (merging) all objects in a library archive into a single object, done with the following command: cc -o lib.o -r -Wl,--whole-archive lib.a The optimization was once useful when no clear distinction was made between compile mode and link-only mode. It was also required for compatibility (see emscripten-core#9510 and emscripten-core#9571). However, emscripten-core#9510 was addressed by emscripten-core#9511, and emscripten-core#9600 introduced the '-r' flag that allows to explicitly indicate linking to an object, making the optimization less useful.
Remove the optimization (again) for the special case of single object input, which skips the linker and directly copies the input object file to output. This behavior interferes with linking (merging) all objects in a library archive into a single object, done with the following command: cc -o lib.o -r -Wl,--whole-archive lib.a The optimization was once useful when no clear distinction was made between compile mode and link-only mode. It was also required for compatibility (see emscripten-core#9510 and emscripten-core#9571). However, emscripten-core#9510 was addressed by emscripten-core#9511, and emscripten-core#9600 introduced the '-r' flag that allows to explicitly indicate linking to an object, making the optimization less useful.
Remove the optimization (again) for the special case of single object input, which skips the linker and directly copies the input object file to output. This behavior interferes with linking (merging) all objects in a library archive into a single object, done with the following command: cc -o lib.o -r -Wl,--whole-archive lib.a The optimization was once useful when no clear distinction was made between compile mode and link-only mode. It was also required for compatibility (see emscripten-core#9510 and emscripten-core#9571). However, emscripten-core#9510 was addressed by emscripten-core#9511, and emscripten-core#9600 introduced the '-r' flag that allows to explicitly indicate linking to an object, making the optimization less useful.
Remove the optimization (again) for the special case of single object input, which skips the linker and directly copies the input object file to output. This behavior interferes with linking (merging) all objects in a library archive into a single object, done with the following command: cc -o lib.o -r -Wl,--whole-archive lib.a The optimization was once useful when no clear distinction was made between compile mode and link-only mode. It was also required for compatibility (see emscripten-core#9510 and emscripten-core#9571). However, emscripten-core#9510 was addressed by emscripten-core#9511, and emscripten-core#9600 introduced the '-r' flag that allows to explicitly indicate linking to an object, making the optimization less useful.
Remove the optimization (again) for the special case of single object input, which skips the linker and directly copies the input object file to output. This behavior interferes with linking (merging) all objects in a library archive into a single object, done with the following command: cc -o lib.o -r -Wl,--whole-archive lib.a The optimization was once useful when no clear distinction was made between compile mode and link-only mode. It was also required for compatibility (see emscripten-core#9510 and emscripten-core#9571). However, emscripten-core#9510 was addressed by emscripten-core#9511, and emscripten-core#9600 introduced the '-r' flag that allows to explicitly indicate linking to an object, making the optimization less useful.
Remove the optimization (again) for the special case of single object
input, which skips the linker and directly copies the input object file
to output.
This behavior interferes with linking (merging) all objects in a
library archive into a single object, done with the following command:
cc -o lib.o -r -Wl,--whole-archive lib.a
The optimization was once useful when no clear distinction was made
between compile mode and link-only mode. It was also required for
compatibility (see #9510 and #9571).
However, #9510 was addressed by #9511, and #9600 introduced the '-r'
flag that allows to explicitly indicate linking to an object, making the
optimization less useful.
Without
-cemscripten will try to run lld on the object files itsgiven to produce another object file. We should probably disable that
for the single build case. This breakage was introduced in #9444 and
we should probably address it, but compiling without
-cis alsobroken so fixing here.
Fixes #9510