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

Enable llvm wasm target #83

Closed
Closed
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
2 changes: 1 addition & 1 deletion .azure-pipelines/azure-pipelines-linux.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .azure-pipelines/azure-pipelines-osx.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .ci_support/linux_64_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ c_compiler_version:
c_stdlib:
- sysroot
c_stdlib_version:
- '2.12'
- '2.28'
cdt_name:
- cos6
channel_sources:
Expand All @@ -17,7 +17,7 @@ cxx_compiler:
cxx_compiler_version:
- '12'
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
- quay.io/condaforge/linux-anvil-alma-x86_64:8
target_platform:
- linux-64
zip_keys:
Expand Down
6 changes: 3 additions & 3 deletions .ci_support/osx_64_.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
MACOSX_DEPLOYMENT_TARGET:
- '10.9'
- '10.13'
MACOSX_SDK_VERSION:
- '10.12'
- '10.13'
c_compiler:
- clang
c_compiler_version:
- '16'
c_stdlib:
- macosx_deployment_target
c_stdlib_version:
- '10.9'
- '10.13'
channel_sources:
- conda-forge
channel_targets:
Expand Down
2 changes: 2 additions & 0 deletions .ci_support/osx_arm64_.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
MACOSX_DEPLOYMENT_TARGET:
- '11.0'
MACOSX_SDK_VERSION:
- '11.0'
c_compiler:
- clang
c_compiler_version:
Expand Down
4 changes: 2 additions & 2 deletions .gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

set -ex


CUR_DIR=`pwd`
cd $HOME

WASI_SDK_DOWNLOAD_LINK=""

if [[ $(uname -s) == "Darwin" ]]; then
if [[ $(uname -m) == "arm64" ]]; then
WASI_SDK_DOWNLOAD_LINK="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-21/wasi-sdk-21.0-macos.tar.gz"
else
WASI_SDK_DOWNLOAD_LINK="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-21/wasi-sdk-21.0-macos.tar.gz"
fi
else
WASI_SDK_DOWNLOAD_LINK="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-21/wasi-sdk-21.0-linux.tar.gz"
fi

echo "WASI SDK download link: $WASI_SDK_DOWNLOAD_LINK"

curl -o wasi-sdk.tar.gz -L $WASI_SDK_DOWNLOAD_LINK
tar -xvf wasi-sdk.tar.gz
export WASI_SDK_PATH=$HOME/wasi-sdk-21.0
echo $WASI_SDK_PATH
$WASI_SDK_PATH/bin/clang --version

cd $CUR_DIR

export CXXFLAGS="${CXXFLAGS} -D__STDC_FORMAT_MACROS -D_LIBCPP_DISABLE_AVAILABILITY"

if [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" == 1 ]]; then
Expand Down Expand Up @@ -33,6 +59,7 @@ if [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" == 1 ]]; then
-DWITH_RUNTIME_LIBRARY=yes \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_INSTALL_LIBDIR=share/lfortran/lib \
-DWITH_TARGET_WASM=yes \
$SRC_DIR
make
)
Expand All @@ -53,6 +80,7 @@ cmake ${CMAKE_ARGS} \
-DWITH_RUNTIME_LIBRARY=$WRT \
-DWITH_RUNTIME_STACKTRACE=yes \
-DCMAKE_INSTALL_LIBDIR=share/lfortran/lib \
-DWITH_TARGET_WASM=yes \
$SRC_DIR

make -j${CPU_COUNT}
Expand Down
7 changes: 5 additions & 2 deletions recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
MACOSX_SDK_VERSION: # [osx and x86_64]
- "10.12" # [osx and x86_64]
docker_image: # [linux and x86_64]
- quay.io/condaforge/linux-anvil-alma-x86_64:8 # [linux and x86_64]

c_stdlib_version:
- '2.28' # [linux]
74 changes: 74 additions & 0 deletions recipe/crtlib_dir.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
diff --git a/src/libasr/config.h b/src/libasr/config.h
new file mode 100644
index 000000000..e45e05ea7
--- /dev/null
+++ b/src/libasr/config.h
@@ -0,0 +1,37 @@
+#ifndef LFORTRAN_CONFIG_H
+#define LFORTRAN_CONFIG_H
+
+/* Define if you want to enable ASSERT testing in LFortran */
+#define WITH_LFORTRAN_ASSERT
+
+/* LFortran version */
+#define LFORTRAN_VERSION "0.35.0-dirty"
+#define LFORTRAN_MAJOR 0
+#define LFORTRAN_MINOR 35
+#define LFORTRAN_PATCHLEVEL 0
+
+/* Define if LLVM is enabled */
+#define HAVE_LFORTRAN_LLVM
+
+/* Define if RAPIDJSON is found */
+/* #undef HAVE_LFORTRAN_RAPIDJSON */
+
+/* Define if stacktrace is enabled */
+#define HAVE_LFORTRAN_STACKTRACE
+#define HAVE_RUNTIME_STACKTRACE
+/* #undef HAVE_LFORTRAN_BFD */
+#define HAVE_LFORTRAN_DWARFDUMP
+/* #undef HAVE_LFORTRAN_LINK */
+#define HAVE_LFORTRAN_MACHO
+#define HAVE_LFORTRAN_UNWIND
+
+/* Define if cxxabi.h is present */
+#define HAVE_LFORTRAN_DEMANGLE
+
+/* Define if XEUS is enabled */
+/* #undef HAVE_LFORTRAN_XEUS */
+
+/* Define if we should use binary modfiles */
+#define WITH_LFORTRAN_BINARY_MODFILES
+
+#endif // LFORTRAN_CONFIG_H
diff --git a/src/runtime/legacy/CMakeLists.txt b/src/runtime/legacy/CMakeLists.txt
index 3795d800c..bebd8460f 100644
--- a/src/runtime/legacy/CMakeLists.txt
+++ b/src/runtime/legacy/CMakeLists.txt
@@ -1,5 +1,5 @@
set(SRC
- ../../../src/libasr/runtime/lfortran_intrinsics.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/libasr/runtime/lfortran_intrinsics.c
Copy link
Member Author

Choose a reason for hiding this comment

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

.

)

if(WIN32)
@@ -31,15 +31,15 @@ if(WITH_TARGET_WASM)
message(FATAL_ERROR "'WASI_SDK_PATH' must be set when building with 'WITH_TARGET_WASM'")
endif()

- add_custom_command(OUTPUT lfortran_runtime_wasm.o
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/lfortran_runtime_wasm.o
COMMAND $ENV{WASI_SDK_PATH}/bin/clang -I${libasr_SOURCE_DIR}/.. -DCOMPILE_TO_WASM
- -D_WASI_EMULATED_PROCESS_CLOCKS -c --target=wasm32-wasi ${SRC} -o lfortran_runtime_wasm.o
+ -D_WASI_EMULATED_PROCESS_CLOCKS -c --target=wasm32-wasi ${SRC} -o ${CMAKE_CURRENT_SOURCE_DIR}/lfortran_runtime_wasm.o
COMMENT "Cross compiling lfortran_intrinscs.c to lfortran_runtime_wasm.o"
DEPENDS ${SRC})
- add_custom_target(lfortran_runtime_wasm ALL DEPENDS lfortran_runtime_wasm.o)
- install(FILES lfortran_runtime_wasm.o
+ add_custom_target(lfortran_runtime_wasm ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lfortran_runtime_wasm.o)
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/lfortran_runtime_wasm.o
DESTINATION ${CMAKE_INSTALL_LIBDIR})
- install(FILES lfortran_runtime_wasm.o
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/lfortran_runtime_wasm.o
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/..)
endif()
3 changes: 3 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ package:
source:
url: https://github.com/lfortran/lfortran/releases/download/v{{ version }}/{{ name }}-{{ version }}.tar.gz
sha256: 5ecc1ae03067b985943c45f6ec05e9f6e72efd6ad004b052e7a98ba552ff79b0
patches:
- crtlib_dir.patch

build:
number: 0

requirements:
build:
- {{ compiler('c') }}
- {{ stdlib('c') }}
- {{ compiler('cxx') }}
- cmake =3.21.1
- make # [unix]
Expand Down
Loading