Skip to content

Fix #2450#2477

Merged
kripken merged 1 commit intoWebAssembly:masterfrom
ImmanuelHaffner:libbinaryen-monolithic
Nov 27, 2019
Merged

Fix #2450#2477
kripken merged 1 commit intoWebAssembly:masterfrom
ImmanuelHaffner:libbinaryen-monolithic

Conversation

@ImmanuelHaffner
Copy link
Copy Markdown
Contributor

@ImmanuelHaffner ImmanuelHaffner commented Nov 26, 2019

Build all libraries of subdirectories as OBJECT libraries. 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. 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)

This fixes #2450

using the `$<TARGET_OBJECTS:objlib>` syntax.  Use this variable when
adding `libbinaryen` as static or shared library.  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)
@kripken
Copy link
Copy Markdown
Member

kripken commented Nov 26, 2019

Thanks! Looks good to me, but we should verify that this works on the Mac bot. Sadly those seem to be very slow, but hopefully later today it'll finish.

@kripken
Copy link
Copy Markdown
Member

kripken commented Nov 27, 2019

Well, no luck on the mac bot on CI, but this looks safe and @aheejin tested locally on a mac, so let's merge and see what happens 😄

@kripken kripken merged commit 5c81d48 into WebAssembly:master Nov 27, 2019
@ImmanuelHaffner
Copy link
Copy Markdown
Contributor Author

Glad I could help. Let's hope for the best. Maybe this has something to do with the version of CMake or Make/Ninja? I guess we can just wait for a new issue to be filed :D

In case someone wants to know how to use Binaryen as CMake ExternalProject_add, see #2450

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.

Binaryen as a subproject: linking to libbinaryen.a gives undefined reference

2 participants