Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Emscripten
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -e -l {0}
jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- name: Emscripten
os: ubuntu-24.04

steps:

- name: Checkout code
uses: actions/checkout@v4

- name: install mamba
uses: mamba-org/setup-micromamba@main
with:
environment-file: environment-wasm-build.yml
init-shell: bash
environment-name: sparrow-wasm-build

- name: Setup default Build Type on *nux
if: ${{ runner.os != 'windows' }}
run: |
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV

- name: Build sparrow
shell: bash -l {0}
run: |
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32

mkdir build
pushd build

export PREFIX=$MAMBA_ROOT_PREFIX/envs/sparrow-wasm-host

emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DUSE_DATE_POLYFILL=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_DOCS=OFF \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fPIC" \
Copy link
Contributor Author

@anutosh491 anutosh491 Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding adding the -fPIC flag here.

Sparrow would build perfectly without it too but if we try to put it to use with xeus-cpp-lite or simply with clang-repl in the browser ..... we would see this error at the linking step.

wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol typeinfo for std::runtime_error; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol std::runtime_error::~runtime_error(); recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol vtable for sparrow::array_wrapper_impl<sparrow::decimal_array<sparrow::decimal<int>>>; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.1; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol typeinfo for std::runtime_error; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol std::runtime_error::~runtime_error(); recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.4; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.4; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.3; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol stderr; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.2; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol vtable for sparrow::array_wrapper_impl<sparrow::dictionary_encoded_array<signed char>>; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.4; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.4; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.3; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol stderr; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.2; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol vtable for sparrow::array_wrapper_impl<sparrow::dictionary_encoded_array<unsigned char>>; recompile with -fPIC
wasm-ld: error: /Users/anutosh491/micromamba/envs/xeus-cpp-wasm-host/lib/libsparrow.a(array_factory.cpp.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str.4; recompile with -fPIC
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
em++: error: '/Users/anutosh491/micromamba/envs/xeus-cpp-wasm-build/bin/wasm-ld @/var/folders/m1/cdn74f917994jd99d_2cpf440000gn/T/emscripten_oj9126u_.rsp.utf-8' failed (returned 1)
make[2]: *** [xcpp.js] Error 1
make[1]: *** [CMakeFiles/xcpp.dir/all] Error 2
make: *** [all] Error 2
emmake: error: 'make install' failed (returned 2)

I was guessing something like -fpic would be taken care of by default but I think I was wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can play around with something like in the cmakelists.txt and address this too !

if (EMSCRIPTEN)
 target_compile_options(sparrow PUBLIC -fPIC)

But yeah the above should be good enough too I think

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..

emmake make -j ${{ env.ncpus }} install

# TODO: Implement a way to execute tests possibly through gtest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


7 changes: 7 additions & 0 deletions environment-wasm-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: sparrow-wasm-build
channels:
- https://repo.prefix.dev/emscripten-forge-dev
- conda-forge
dependencies:
- cmake
- emscripten_emscripten-wasm32==3.1.73
5 changes: 5 additions & 0 deletions environment-wasm-host.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: sparrow-wasm-host
channels:
- https://repo.prefix.dev/emscripten-forge-dev
dependencies:
- howardhinnant_date
Loading