Skip to content

Conversation

ex0dus-0x
Copy link
Collaborator

No description provided.

@ekilmer ekilmer requested review from Jezurko and frabert September 19, 2025 18:35
@frabert
Copy link
Collaborator

frabert commented Sep 22, 2025

LGTM as far as the changes go, currently waiting for the LLVM test suite to compile & pass

Comment on lines 343 to 383
// Handle external weak linkage conflicts
if (isExternalWeakLinkage(srcLinkage)) {
if (isExternalWeakLinkage(dstLinkage)) {
// Both external weak, keep dst
return ConflictResolution::LinkFromDst;
}
if (isExternalLinkage(dstLinkage) || isWeakForLinker(dstLinkage)) {
// External weak loses to external or other weak
return ConflictResolution::LinkFromDst;
}
// External weak wins over declarations
if (dstIsDeclaration) {
return ConflictResolution::LinkFromSrc;
}
return ConflictResolution::LinkFromDst;
}

if (isExternalWeakLinkage(dstLinkage)) {
if (isExternalLinkage(srcLinkage) || isWeakForLinker(srcLinkage)) {
// External or weak src wins over external weak dst
return ConflictResolution::LinkFromSrc;
}
// External weak wins over declarations
if (srcIsDeclaration) {
return ConflictResolution::LinkFromDst;
}
return ConflictResolution::LinkFromSrc;
}

// Handle available externally + external definition conflicts
if (isAvailableExternallyLinkage(srcLinkage) &&
isExternalLinkage(dstLinkage)) {
// External definition wins over available externally
return ConflictResolution::LinkFromDst;
}

if (isAvailableExternallyLinkage(dstLinkage) &&
isExternalLinkage(srcLinkage)) {
// External definition wins over available externally
return ConflictResolution::LinkFromSrc;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part seems a bit strange to me…
llvm-link does not have to handle this (see their implementation of conflict resolution) and it seems like quite a lot of potentially unresolved conflicts they would encounter.

Was this maybe necessary to add because of some other bug? Where/when did you encounter these unresolved conflicts?

Copy link
Collaborator Author

@ex0dus-0x ex0dus-0x Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for safety I added conditionals to cover all other cases that didn't look to be covered, particularly for situations where it seems both symbols have definitions already from the targets. Will reinvestigate to see if its extraneous. This was for analyze-image and ros2.

For ros2 specifically:

colcon build --merge-install --base-paths src --cmake-args -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} --parallel-workers $(nproc) --packages-select iceoryx_hoofs
...
OBJ: Added input object CMakeFiles/iceoryx_hoofs.dir/source/log/logging.cpp.o
OBJ: Added input object CMakeFiles/iceoryx_hoofs.dir/source/log/logging_internal.cpp.o
unimplemented conflict resolution
UNREACHABLE executed at /home/alancao/instafix-llvm/llvm/out/install/linux/include/mlir/Linker/LLVMLinkerMixin.h:413!
cannot parse input module libiceoryx_hoofs.so

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I will try to give it a look to see if that's a symptom of some other bug or if this is a legal case.
IIUIC, there are some invalid cases that should not pop-up (or should not allow linking to continue), so that's why I'm trying to be careful around it :)

Comment on lines +508 to +542
if (globs.empty()) {
if (auto found = summary.find(glob); found != summary.end())
return state.clone(found->second);
return nullptr;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a test-case for this? Unless it's too complicated.
Feels like we are chasing bugs in this part, so it would be good to have regression tests

@ex0dus-0x
Copy link
Collaborator Author

@Jezurko apologies for the delay, was working heavily on the recursive dynamic linking. I've minified the PR to only handle the particular cases in ros2 that were causing the unimplemented conflict resolution, the other symbol changes were mainly "cover all cases" but I understand we want to maintain parity with the original llvm-link.

The particular component in ros2, iceoryx_hoofs had these symbols that were problematic that our cases now handle:

DEBUG: Src is declaration, dst is definition for symbol: _ZN3iox3log16LoggingComponent3CtxE
DEBUG: Src is declaration, dst is definition for symbol: _ZN3iox3log16LoggingComponent11DescriptionE
DEBUG: Src is declaration, dst is definition for symbol: _ZN3iox5posix18SharedMemoryObject15NO_ADDRESS_HINT[[[E

which would correspond to

    if (srcIsDeclaration && !dstIsDeclaration)
      return ConflictResolution::LinkFromDst;

@ex0dus-0x ex0dus-0x force-pushed the alan/more-symb-fixes branch from 4a28fb4 to 2c230e4 Compare October 8, 2025 18:36
Copy link
Collaborator

@Jezurko Jezurko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) Sorry for taking so long to respond

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 this pull request may close these issues.

3 participants