-
Notifications
You must be signed in to change notification settings - Fork 14
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
Shared lib for tt-forge
#257
Conversation
In `tt-forge` we manually add each library from `tt-mlir`, which is error prone. This PR adds `TTMLIRSO.so` shared lib which will be only lib used by `tt-forge`. Notes: * This won't solve `RTTI` issue * `--whole-archive` is needed to pull all symbols into shard lib
TTRuntime | ||
TTRuntimeTTNN | ||
# MLIR libraries | ||
-Wl,--no-whole-archive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing these linker flags we should change the target_link_libraries
, PRIVATE
to PUBLIC
, which should export the symbols of these static libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this work because tt-mlir
is built in separate project and its targets are not visible to tt-forge
, hence adding public wouldn't change anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think PUBLIC
implies -Wl,--no-whole-archive
, would you mind trying?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean PUBLIC implies -Wl,--whole-archive
?
Btw, I tried PUBLIC
initially, thats how I've ended up with whole-archive
. Just to confirm I tried it again today and same issue. But I will try again to be triple sure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I don't want to block the review because we should get this in. But something else must be messed up somewhere in the cmake tree, this is what PUBLIC
means so I'm not sure why it would be hiding the symbols.
* Removing repeating libs * Adding `DEVICE_LIBRARY` target * Fixing library ordering in `third_party` `CMakeLists.txt`
${TTNN_LIBS} | ||
) | ||
|
||
target_link_libraries(TTMLIR PRIVATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be PUBLIC
, all of the symbols from TTMLIR_LIBS should be made available to front ends. We can drop the -Wl,--whole-archive
below. See docs: https://cmake.org/cmake/help/latest/command/target_link_libraries.html#libraries-for-a-target-and-or-its-dependents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left comment above with screen shot but I will write here again. Adding PUBLIC
would work if tt-forge
and tt-mlir
was built as one single project.
target_link_libraries(TTMLIR PUBLIC SomeStaticLib)
If you have above this implies:
- Link
SomeStaticLib
toTTMLIR
- Link
SomeStaticLib
to any lib which links againstTTMLIR
directly (translative property ofPUBLIC
)
So if I have some third lib inside the project say TTMLIR2
and I link against TTMLIR
cmake is going to inline all libs from TTMLIR
to TTMLIR2
.
All above works for all libs inside cmake
project which means it wont work between tt-forge
and tt-mlir
since they are compiled separately (i.e targets from mlir
are not visible to forge
)
If you are not convinced ping me offline we can discuss :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nsmithtt Ping on this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't matter, TTMLIR
target is a final executable, the static libs linked into it if marked PUBLIC
means to export their symbols into the dylib. I think there must be something somewhere else in the cmake tree that's messing with this. Anyway, we can revisit, let's get this in as is :)
In
tt-forge
we manually add each library fromtt-mlir
, which is error prone. This PR addsTTMLIRSO.so
shared lib which will be only lib used bytt-forge
.Notes:
RTTI
issue--whole-archive
is needed to pull all symbols into shard lib