Skip to content
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

Warnings while building shared library through cmake #23361

Open
anutosh491 opened this issue Jan 10, 2025 · 3 comments
Open

Warnings while building shared library through cmake #23361

anutosh491 opened this issue Jan 10, 2025 · 3 comments

Comments

@anutosh491
Copy link

Using emsdk 3.1.45

I am trying to build a shared lib for a the cppinterop library.

The cmake goes like this

  set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
  set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
  set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
  set(CMAKE_STRIP FALSE)

  add_library(clangCppInterOp SHARED
    CppInterOp.cpp
    CXCppInterOp.cpp
    DynamicLibraryManager.cpp
    DynamicLibraryManagerSymbol.cpp
    Paths.cpp
  )

  target_link_libraries(clangCppInterOp clangInterpreter)
  )

The first 4 lines are inspired by this comment on how to build shared libs through cmake (#15276 (comment) )

Now while building it I see the following warnings/errors (the build is succesful and i can make use of it though)

(xeus-cpp-wasm-build) anutosh491@Anutoshs-MacBook-Air build2 % emmake make -j1
make: make -j1
[ 16%] Linking CXX shared library ../libclangCppInterOp.so
em++: warning: ignoring unsupported linker flag: `-soname` [-Wlinkflags]
wasm-ld: warning: unknown -z value: defs
@anutosh491
Copy link
Author

If I see the link.txt I see quite some things that won't be required including (-z,defs and -soname)

/Users/anutosh491/work/emsdk/upstream/emscripten/em++ -fPIC -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -O3 -DNDEBUG -Wl,--export=__clang_Interpreter_SetValueNoAlloc -Wl,-z,defs -s SIDE_MODULE=1 -Wl,-soname,libclangCppInterOp.so -o ../libclangCppInterOp.so @CMakeFiles/clangCppInterOp.dir/objects1.rsp @CMakeFiles/clangCppInterOp.dir/linkLibs.rsp

  1. two fpic's to begin with, I didn't add any.
  2. Lot of warnings like -Werror=date-time which I am not sure how they are coming from, again didn't add any.
  3. -Wl,-z,defs and -Wl,-soname,libclangCppInterOp.so -o ../libclangCppInterOp.so ... not sure how crucial are these and where are they coming from.

I guess I am just looking for the SIDE_MODULE=1 flag. So yeah lot of unncessary things here.

Any help to figure out how I could clean this up would be really great.

@anutosh491 anutosh491 changed the title Warnings while building shared library Warnings while building shared library through cmake Jan 10, 2025
@sbc100
Copy link
Collaborator

sbc100 commented Jan 10, 2025

I believe those flags are all coming from the llvm build system, nothing to do with emscripten per-say.

@anutosh491
Copy link
Author

anutosh491 commented Jan 11, 2025

Oops okay, I didn't realize it would work that way !

So we build libclangInterpreter.a (while building llvm i.e clang and lld for wasm using emscripten) and then want to make use of it through
target_link_libraries(clangCppInterOp clangInterpreter)

Still not sure how the flags are being propagated into CppInterOp's build here but yeah I might have to educate myself here.

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

No branches or pull requests

2 participants