Skip to content

Fix Object libraries cause problem on the mac build bot#2472

Closed
ImmanuelHaffner wants to merge 1 commit intoWebAssembly:masterfrom
ImmanuelHaffner:libbinaryen-fix-objectlibary-not-linkable
Closed

Fix Object libraries cause problem on the mac build bot#2472
ImmanuelHaffner wants to merge 1 commit intoWebAssembly:masterfrom
ImmanuelHaffner:libbinaryen-fix-objectlibary-not-linkable

Conversation

@ImmanuelHaffner
Copy link
Contributor

@ImmanuelHaffner ImmanuelHaffner commented Nov 25, 2019

Collect all object files from the object libraries in a CMake variable using the $<TARGET_OBJECTS:objlib> syntax.
Use this variable when adding libbinaryen as static or shared library.
Using the object files in the add_library command should be most
portable.
Additionally, use the variable with the object files to simplify the
TARGET_LINK_LIBRARIES commands.

This fixes #2471.

@ImmanuelHaffner ImmanuelHaffner changed the title Fix #2471 Fix Object libraries cause problem on the mac build bot Nov 25, 2019
@kripken
Copy link
Member

kripken commented Nov 25, 2019

Thanks @ImmanuelHaffner!

Testing locally, I see the same errors as on CI, No rule to make target [..] pass.cpp etc. Oddly, when I just run make again after that, it works...

@ImmanuelHaffner
Copy link
Contributor Author

ImmanuelHaffner commented Nov 25, 2019

Oh damn. Could that mean that dependencies are missing...?

@kripken
Copy link
Member

kripken commented Nov 25, 2019

Doing some searching, I think the issue is that object libraries must be sources, not link flags, see

https://cmake.org/pipermail/cmake/2018-June/067721.html

With this patch I seem to get further, but hit another error, https://gist.github.com/kripken/56fbec00a34be9ed50522a0d5ddb298a

@kripken
Copy link
Member

kripken commented Nov 25, 2019

Oh, with that patch it looks like none of those libraries are linked in at all :( Anyhow, I'm not sure what's going on here, but that link does look relevant?

@ImmanuelHaffner
Copy link
Contributor Author

ImmanuelHaffner commented Nov 25, 2019

Oh I see the problem. The binaryen_objs should be added to the add_executable and not target_link_libraries commands. As your source suggests, they must be listed as sources not linker arguments.
I will look into this tomorrow morning. It's just weird my system and my colleagues build the project just fine.

@kripken
Copy link
Member

kripken commented Nov 25, 2019

Yes, but that doesn't seem to work in my patch when I tried it... but maybe I did something wrong?

@kripken
Copy link
Member

kripken commented Nov 25, 2019

@ImmanuelHaffner

It looks like we don't have a fix for this today - I looked into a little more myself, but didn't figure it out. So I think we should revert the breaking PR. I'll wait a bit just in case you were about to update this PR, but otherwise will revert it. We can continue to figure out a proper fix after that.

using the `$<TARGET_OBJECTS:objlib>` syntax.
Use this variable when adding `libbinaryen` as static or shared library.
Using the object files in the `add_library` command should be most
portable.
Additionally, use the variable with the object files to simplify the
`TARGET_LINK_LIBRARIES` commands: add the object libraries to the
sources of executables and drop the use of our libraries in
`TARGET_LINK_LIBRARIES`.  (Object libraries cannot be linked but must be
used as sources.  See
https://cmake.org/pipermail/cmake/2018-June/067721.html)
@ImmanuelHaffner ImmanuelHaffner mentioned this pull request Nov 26, 2019
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.

Object libraries cause problem on the mac build bot

2 participants