-
Notifications
You must be signed in to change notification settings - Fork 2k
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
build system: link object files #14754
Conversation
2d6358f
to
9000eed
Compare
6f793d2
to
6ea75e6
Compare
Many changes that are currently in the PR can and should be split. I'll do so if we agree with the change. |
6ea75e6
to
f8d25ac
Compare
Could this fix the issue that randomly a weak symbol is linked in instead of a strong symbol? I had this issue when working with a local PKG and in the end resorted to using guardimg the weak symbol with |
Yes. That's because of the way the linker is picking the objects that provide needed symbols from the archives, which depends of the order of the archives on the list, and the name of the objects. Using objects it should link the strong symbol, and throw an error when more than one strong symbol is found. For examples of this, see the |
I'm on it. I could not reproduce at first but when building in Docker the error pops up. |
The regression seems to be caused by the commit you pointed out. I'm debugging to figure out why the call to My clang version outside docker is:
|
I've opened an issue to track the regression, see #15066 |
This broke the output on esp8266 #15137 (That might also be the reason why esp32 tests are failing on CI) |
Interestingly, the output of Seemingly, symbol |
This could be the case for other functions defined as weak, which did not get overridden before and now are. I'll look into this. |
That's not true. The |
I'm also getting a big output with this tool. Interestingly, it points out that one symbol disappeared and one symbol is new (main):
|
Strange. It changed by 100 Byte and the machine code looks pretty different. I wonder what else could explain this :-/ Here is by the way the output of I sadly forgot to overwrite |
Please see #15186 |
Because of this PR, it is somehow no longer possible to build anything on the nucleo-f207zg :/
|
Can you try |
Oh damn, I didn't see this :D. |
With the change from using archive files to using object files in PR RIOT-OS#14754, the module `esp_wifi_enterprise` was no longer compilable. The reason for this was that the file `bignum.c` was present in two different vendor sub-directories and created two identical object files, which then led to a symbol conflict when linking. This commit removes one of these identical files. The one that is used in all `esp_wifi` variants is kept, the one that is only used in `esp_wifi_enterprise` is dropped.
With the change from using archive files to using object files in PR RIOT-OS#14754, the module `esp_wifi_enterprise` was no longer compilable. The reason for this was that the file `bignum.c` was present in two different vendor sub-directories and created two identical object files, which then led to a symbol conflict when linking. This commit removes one of these identical files. The one that is used in all `esp_wifi` variants is kept, the one that is only used in `esp_wifi_enterprise` is dropped.
With the change from using archive files to using object files in PR RIOT-OS#14754, the module `esp_wifi_enterprise` was no longer compilable. The reason for this was that the file `bignum.c` was present in two different vendor sub-directories and created two identical object files, which then led to a symbol conflict when linking. This commit removes one of these identical files. The one that is used in all `esp_wifi` variants is kept, the one that is only used in `esp_wifi_enterprise` is dropped.
Contribution description
This PR is another attempt to use the generated object files for the linking step instead of the archives. This makes the linking process more transparent and helps pointing out possible redefinition of symbols that may not have been caught before. It also saves a small amount of time by no dealing with the archive creation. The
UNDEF
list of objects is not needed anymore.The PR also fixes the
bindist
example which is broken in current master. The archive seems to be malformed and the second linking is not possible. The example now copies the object files for the second linking.Current problem
Currently we are using mostly archives in the linking step (only object files specified in the
UNDEF
makefile variable will be linked directly). That means that:As we link archives and not objects the order really matters, because of the algorithm the linker uses to pick objects from those archives. We may be masking errors of multiple symbol definitions, which could be dangerous (see the example bellow).
We are generating one archive per module (even when some modules don't have any object files, e.g.
sys
orgnrc
). This produced some issue in OSx apparently and we found a workaround to be able to link empty archives.As archives may have circular dependencies between them, we are forced to use the
--start-group
and--end-group
options for all our archives. According toman ld
, "Using this option has a significant performance cost".An example of the problem
As order matters, and we use alphabetical order to link the archives, we are currently not overriding the
weak
kly definedpanic_arch
function, and using always the version provided by the core. To see this, just compile some example on an architecture that overrides this (e.g. any cortexm), and inspect the binary (nm bin/samr21-xpro/gcoap_example.elf
), the symboltype will be
W
. This could happen with other symbols in other modules, and depends on which other modules are being used and their order in the linking process.Testing procedure
Issues/PRs references
Alternative to #8711
Initial suggestion in #5757