kou commented on code in PR #37821:
URL: https://github.com/apache/arrow/pull/37821#discussion_r1348205281


##########
cpp/cmake_modules/SetupCxxFlags.cmake:
##########
@@ -700,3 +702,30 @@ if(MSVC)
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} 
${MSVC_LINKER_FLAGS}")
   endif()
 endif()
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+  # flags are:
+  # 1) We're using zlib from Emscripten ports
+  # 2) We are building library code
+  # 3) We force *everything* to build as position independent
+  # 4) And with support for C++ exceptions
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sUSE_ZLIB=1  -fPIC -fexceptions")
+  # size_t is 32 bit in emscripten wasm32 - ignore conversion errors
+  # deprecated-literal-operator error is thrown in datetime (vendored lib in 
arrow)
+  set(CMAKE_CXX_FLAGS
+      "${CMAKE_CXX_FLAGS} -sUSE_ZLIB=1 -fPIC -fexceptions 
-Wno-error=shorten-64-to-32 -Wno-error=deprecated-literal-operator"

Review Comment:
   Hmm.
   I got the following error with `-Wno-error=deprecated-literal-operator`:
   
   ```text
   [17/427] Building CXX object 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
   FAILED: 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o 
   /bin/ccache /bin/em++ -DARROW_EXTRA_ERROR_CONTEXT -DARROW_WITH_TIMING_TESTS 
-isystem cpp.build.emscripten/_deps/googletest-src/googlemock/include -isystem 
cpp.build.emscripten/_deps/googletest-src/googlemock -isystem 
cpp.build.emscripten/_deps/googletest-src/googletest/include -isystem 
cpp.build.emscripten/_deps/googletest-src/googletest -Qunused-arguments 
-fcolor-diagnostics -fPIC -fexceptions -Wno-error=shorten-64-to-32 
-Wno-error=deprecated-literal-operator -g -Werror -O0 -ggdb  -Wno-error 
-std=c++17 -fPIC -Wall -Wshadow -Werror -Wconversion -DGTEST_HAS_PTHREAD=1 
-fexceptions -W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings 
-Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline 
-Wredundant-decls -MD -MT 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o 
-MF 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o.d
 -o 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o 
-c cp
 p.build.emscripten/_deps/googletest-src/googlemock/src/gmock_main.cc
   error: unknown warning option '-Werror=deprecated-literal-operator'; did you 
mean '-Werror=deprecated-copy-dtor'? [-Werror,-Wunknown-warning-option]
   em++: error: '/usr/bin/clang++-14 -target wasm32-unknown-emscripten 
-DEMSCRIPTEN -D__EMSCRIPTEN_major__=3 -D__EMSCRIPTEN_minor__=1 
-D__EMSCRIPTEN_tiny__=6 -fvisibility=default -mllvm 
-combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions 
-mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D_LIBCPP_ABI_VERSION=2 
-fno-threadsafe-statics -Dunix -D__unix -D__unix__ 
-Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL 
--sysroot=/usr/share/emscripten/cache/sysroot -Xclang 
-iwithsysroot/include/compat -Qunused-arguments -fcolor-diagnostics -fPIC 
-fexceptions -Wno-error=shorten-64-to-32 -Wno-error=deprecated-literal-operator 
-g -O0 -ggdb -std=c++17 -fPIC -Wall -Wshadow -Wconversion -fexceptions -W 
-Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch 
-Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls 
-Werror -Wno-error -Werror -DARROW_EXTRA_ERROR_CONTEXT 
-DARROW_WITH_TIMING_TESTS -isystem cpp.build.emscripte
 n/_deps/googletest-src/googlemock/include -isystem 
cpp.build.emscripten/_deps/googletest-src/googlemock -isystem 
cpp.build.emscripten/_deps/googletest-src/googletest/include -isystem 
cpp.build.emscripten/_deps/googletest-src/googletest -DGTEST_HAS_PTHREAD=1 -c 
-MD -MT 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o 
-MF 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o.d
 cpp.build.emscripten/_deps/googletest-src/googlemock/src/gmock_main.cc -o 
_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o'
 failed (returned 1)
   ```



##########
cpp/cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -955,6 +955,21 @@ set(EP_COMMON_CMAKE_ARGS
     -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
     -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE})
 
+# if building with a toolchain file, pass that through
+if(CMAKE_TOOLCHAIN_FILE)
+  list(APPEND EP_COMMON_CMAKE_ARGS 
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
+endif()
+
+# and crosscompiling emulator (for try_run() )
+if(CMAKE_CROSSCOMPILING_EMULATOR)
+  list(APPEND EP_COMMON_CMAKE_ARGS
+       -DCMAKE_CROSSCOMPILING_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR})

Review Comment:
   We need to escape `;` (list element separator) to pass external project:
   
   ```suggestion
     string(REPLACE ";" ${EP_LIST_SEPARATOR} EP_CMAKE_CROSSCOMPILING_EMULATOR
                    "${CMAKE_CROSSCOMPILING_EMULATOR}")
     list(APPEND EP_COMMON_CMAKE_ARGS
          -DCMAKE_CROSSCOMPILING_EMULATOR=${EP_CMAKE_CROSSCOMPILING_EMULATOR})
   ```



##########
cpp/cmake_modules/SetupCxxFlags.cmake:
##########
@@ -700,3 +702,30 @@ if(MSVC)
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} 
${MSVC_LINKER_FLAGS}")
   endif()
 endif()
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+  # flags are:
+  # 1) We're using zlib from Emscripten ports
+  # 2) We are building library code
+  # 3) We force *everything* to build as position independent
+  # 4) And with support for C++ exceptions
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sUSE_ZLIB=1  -fPIC -fexceptions")
+  # size_t is 32 bit in emscripten wasm32 - ignore conversion errors
+  # deprecated-literal-operator error is thrown in datetime (vendored lib in 
arrow)
+  set(CMAKE_CXX_FLAGS
+      "${CMAKE_CXX_FLAGS} -sUSE_ZLIB=1 -fPIC -fexceptions 
-Wno-error=shorten-64-to-32 -Wno-error=deprecated-literal-operator"

Review Comment:
   #38090 for `shorten-64-to-32`.



-- 
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