From b862182eee66a3d9cfd16b8de1ab2aaf8794eb70 Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Sun, 12 Jan 2025 23:48:05 +0000 Subject: [PATCH 1/3] Remove soname and zdefs flags emscripten build --- .github/workflows/emscripten.yml | 2 ++ lib/Interpreter/CMakeLists.txt | 7 ++++++ .../emscripten-clang19-3-remove-zdefs.patch | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 patches/llvm/emscripten-clang19-3-remove-zdefs.patch diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 381feb564..18db5a608 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -575,6 +575,7 @@ jobs: -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + -DLLVM_ENABLE_WERROR=On \ ../ else emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ @@ -586,6 +587,7 @@ jobs: -DCODE_COVERAGE=${{ env.CODE_COVERAGE }} \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \ + -DLLVM_ENABLE_WERROR=On \ ../ fi diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt index ba699dc83..977573474 100644 --- a/lib/Interpreter/CMakeLists.txt +++ b/lib/Interpreter/CMakeLists.txt @@ -17,6 +17,13 @@ if(EMSCRIPTEN) LINK_LIBS clangInterpreter ) + #FIXME: This is needed until https://github.com/emscripten-core/emscripten/blob/ac676d5e437525d15df5fd46bc2c208ec6d376a3/cmake/Modules/Platform/Emscripten.cmake#L36 + # is patched out of emsdk, as --soname is not recognised by emscripten. + #FIXME: A patch is needed to llvm to remove -Wl,-z,defs since it is now recognised on emscripten. What needs to be removed is here + # https://github.com/llvm/llvm-project/blob/128e2e446e90c3b1827cfc7d4d19e3c0976beff3/llvm/cmake/modules/HandleLLVMOptions.cmake#L318 + set_target_properties(clangCppInterOp + PROPERTIES NO_SONAME 1 +) target_link_options(clangCppInterOp PRIVATE PUBLIC "SHELL: -s WASM_BIGINT" ) diff --git a/patches/llvm/emscripten-clang19-3-remove-zdefs.patch b/patches/llvm/emscripten-clang19-3-remove-zdefs.patch new file mode 100644 index 000000000..ca80574b8 --- /dev/null +++ b/patches/llvm/emscripten-clang19-3-remove-zdefs.patch @@ -0,0 +1,22 @@ +diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake +index 5ca580fbb..d39b2eb7e 100644 +--- a/llvm/cmake/modules/HandleLLVMOptions.cmake ++++ b/llvm/cmake/modules/HandleLLVMOptions.cmake +@@ -299,7 +299,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "AIX") + message(WARNING "Build and install environment path info may be exposed; binaries will also be unrelocatable.") + endif() + endif() +- ++#ifndef EMSCRIPTEN + # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO + # build might work on ELF but fail on MachO/COFF. + if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390" OR +@@ -307,7 +307,7 @@ if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390" O + NOT LLVM_USE_SANITIZER) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") + endif() +- ++#endif + # Pass -Wl,-z,nodelete. This makes sure our shared libraries are not unloaded + # by dlclose(). We need that since the CLI API relies on cross-references + # between global objects which became horribly broken when one of the libraries From a90db5d27e41d72e93c5fa1ea14e03d1f3d14d6d Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Fri, 17 Jan 2025 21:08:41 +0000 Subject: [PATCH 2/3] Reference PRs where fixes for unwanted flags are. --- lib/Interpreter/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Interpreter/CMakeLists.txt b/lib/Interpreter/CMakeLists.txt index 977573474..933505691 100644 --- a/lib/Interpreter/CMakeLists.txt +++ b/lib/Interpreter/CMakeLists.txt @@ -17,10 +17,11 @@ if(EMSCRIPTEN) LINK_LIBS clangInterpreter ) - #FIXME: This is needed until https://github.com/emscripten-core/emscripten/blob/ac676d5e437525d15df5fd46bc2c208ec6d376a3/cmake/Modules/Platform/Emscripten.cmake#L36 - # is patched out of emsdk, as --soname is not recognised by emscripten. + #FIXME: Setting no_soname=1 is needed until https://github.com/emscripten-core/emscripten/blob/ac676d5e437525d15df5fd46bc2c208ec6d376a3/cmake/Modules/Platform/Emscripten.cmake#L36 + # is patched out of emsdk, as --soname is not recognised by emscripten. A PR to do this has been done here https://github.com/emscripten-core/emscripten/pull/23453 #FIXME: A patch is needed to llvm to remove -Wl,-z,defs since it is now recognised on emscripten. What needs to be removed is here - # https://github.com/llvm/llvm-project/blob/128e2e446e90c3b1827cfc7d4d19e3c0976beff3/llvm/cmake/modules/HandleLLVMOptions.cmake#L318 + # https://github.com/llvm/llvm-project/blob/128e2e446e90c3b1827cfc7d4d19e3c0976beff3/llvm/cmake/modules/HandleLLVMOptions.cmake#L318 . The PR to do try to do this is here + # https://github.com/llvm/llvm-project/pull/123396 set_target_properties(clangCppInterOp PROPERTIES NO_SONAME 1 ) From 24a423cb5ab3a03ed9ad48ba548311a6b0ecfc7c Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Fri, 17 Jan 2025 21:15:16 +0000 Subject: [PATCH 3/3] Update patch with suggestion from PR --- .../emscripten-clang19-3-remove-zdefs.patch | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/patches/llvm/emscripten-clang19-3-remove-zdefs.patch b/patches/llvm/emscripten-clang19-3-remove-zdefs.patch index ca80574b8..6d897e067 100644 --- a/patches/llvm/emscripten-clang19-3-remove-zdefs.patch +++ b/patches/llvm/emscripten-clang19-3-remove-zdefs.patch @@ -1,22 +1,13 @@ diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake -index 5ca580fbb..d39b2eb7e 100644 +index 5ca580fbb..cff186b7b 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake -@@ -299,7 +299,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "AIX") - message(WARNING "Build and install environment path info may be exposed; binaries will also be unrelocatable.") - endif() - endif() -- -+#ifndef EMSCRIPTEN +@@ -302,7 +302,7 @@ endif() + # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO # build might work on ELF but fail on MachO/COFF. - if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390" OR -@@ -307,7 +307,7 @@ if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390" O +-if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390" OR ++if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|OS390|Emscripten" OR + WIN32 OR CYGWIN) AND NOT LLVM_USE_SANITIZER) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") - endif() -- -+#endif - # Pass -Wl,-z,nodelete. This makes sure our shared libraries are not unloaded - # by dlclose(). We need that since the CLI API relies on cross-references - # between global objects which became horribly broken when one of the libraries