agriyakhetarpal commented on code in PR #47330:
URL: https://github.com/apache/arrow/pull/47330#discussion_r3789823486


##########
cpp/cmake_modules/SetupCxxFlags.cmake:
##########
@@ -719,26 +719,35 @@ if(MSVC)
 endif()
 
 if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
-  # flags are:
+  # For the Pyodide 2026_0 ABI, the flags are:
   # 1) We force *everything* to build as position independent
-  # 2) And with support for C++ exceptions
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fexceptions")
+  # 2) We support C++ WASM exceptions, using the native WebAssembly
+  #    exception handling proposal and WebAssembly-based setjmp/longjmp
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fwasm-exceptions 
-sSUPPORT_LONGJMP=wasm")
   # deprecated-literal-operator error is thrown in datetime (vendored lib in 
arrow)
   set(CMAKE_CXX_FLAGS
-      "${CMAKE_CXX_FLAGS} -fPIC -fexceptions 
-Wno-error=deprecated-literal-operator")
+      "${CMAKE_CXX_FLAGS} -fPIC -fwasm-exceptions -sSUPPORT_LONGJMP=wasm 
-Wno-error=deprecated-literal-operator"
+  )
 
   # flags for creating shared libraries (only used in pyarrow, because
   # Emscripten builds libarrow as static)
   # flags are:
   # 1) Tell it to use JavaScript / WebAssembly 64 bit number support.
-  # 2) Tell it to build with support for C++ exceptions
+  # 2) Tell it to build with support for C++ exceptions (see above)
   # 3) Skip linker flags error which happens with -soname parameter
-  set(ARROW_EMSCRIPTEN_LINKER_FLAGS "-sWASM_BIGINT=1 -fexceptions 
-Wno-error=linkflags")
-  set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS
-      "-sSIDE_MODULE=1 ${ARROW_EMSCRIPTEN_LINKER_FLAGS}")
-  set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS
-      "-sSIDE_MODULE=1 ${ARROW_EMSCRIPTEN_LINKER_FLAGS}")
-  set(CMAKE_SHARED_LINKER_FLAGS "-sSIDE_MODULE=1 
${ARROW_EMSCRIPTEN_LINKER_FLAGS}")
+  # 4) Record $ORIGIN as an RPATH, so that Pyodide can locate
+  #    libarrow_python.so next to the extension modules needing it
+  # Note: the CMAKE_SHARED_LIBRARY_CREATE_<LANG>_FLAGS and
+  # CMAKE_SHARED_MODULE_CREATE_<LANG>_FLAGS variables are not used by the
+  # Ninja generator, so the flags must go through the linker-flags
+  # variables, which apply to SHARED (libarrow_python) and MODULE (Cython
+  # extension) targets respectively.
+  set(ARROW_EMSCRIPTEN_LINKER_FLAGS
+      "-sWASM_BIGINT=1 -fwasm-exceptions -sSUPPORT_LONGJMP=wasm 
-Wno-error=linkflags")
+  set(ARROW_EMSCRIPTEN_DYLIB_CREATE_FLAGS
+      "-sSIDE_MODULE=1 ${ARROW_EMSCRIPTEN_LINKER_FLAGS} '-Wl,-rpath,$ORIGIN'")

Review Comment:
   This one should be incorrect, because these linker-flags variables are 
pasted verbatim into the link command, which Ninja runs through `/bin/sh`, so 
the single quotes are consumed by the shell and keep `$ORIGIN` from being 
expanded as a shell variable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to