diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..6b18af3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04 + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + software-properties-common fish + +RUN add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" +RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + clang-19 clang++-19 llvm-19-dev libmlir-19-dev mlir-19-tools \ + rake python3-pip libzstd-dev + +RUN pip install lit filecheck==0.0.24 pre-commit --break-system-packages diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..021a703 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,15 @@ +{ + "name": "Lightstorm", + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + // Switch to the "official" version as soon as + // https://github.com/devcontainers-community/features-cmake/pull/2 + // merged + "ghcr.io/alexdenisov/features/feature-cmake": { + "version": "3.29.3" + } + }, + "postCreateCommand": "sh .devcontainer/post_create.sh" +} diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh new file mode 100644 index 0000000..6e157a8 --- /dev/null +++ b/.devcontainer/post_create.sh @@ -0,0 +1,4 @@ +set -e + +pre-commit install +git submodule update --init --recursive diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml new file mode 100644 index 0000000..dce2b5c --- /dev/null +++ b/.github/workflows/linux-ci.yml @@ -0,0 +1,22 @@ +name: Linux CI +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/dragonruby/internal-lightstorm-ci + runCmd: | + cmake --preset lightstorm + cmake --build ./build.debug.dir/build -t run-integration-tests diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index dcbf795..88a53f5 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -5,12 +5,8 @@ on: pull_request: branches: ["main"] jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-latest] + build-and-test: + runs-on: macos-latest steps: - uses: actions/checkout@v4 with: diff --git a/.gitignore b/.gitignore index 83260f8..46f8468 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ Output +build*dir +*.lit_test_times.txt diff --git a/.gitmodules b/.gitmodules index 03be569..244af92 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "third_party/mruby"] path = third_party/mruby - url = git@github.com:mruby/mruby.git + url = https://github.com/mruby/mruby.git diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..73c8daf --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,19 @@ +{ + "version": 8, + "configurePresets": [ + { + "name": "lightstorm", + "displayName": "lightstorm", + "description": "Sets Ninja generator, build and install directory", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build.debug.dir/build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "clang-19", + "CMAKE_CXX_COMPILER": "clang++-19", + "CMAKE_PREFIX_PATH": "/usr/lib/llvm-19/lib/cmake", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build.debug.dir/install" + } + } + ] +} diff --git a/cmake/mruby.cmake b/cmake/mruby.cmake index 0ca3c9a..a47acda 100644 --- a/cmake/mruby.cmake +++ b/cmake/mruby.cmake @@ -8,8 +8,10 @@ ExternalProject_Add( mruby SOURCE_DIR ${MRUBY_DIR} CONFIGURE_COMMAND "" - BUILD_COMMAND ${CMAKE_COMMAND} -E env CFLAGS="${LIGHTSTORM_CFLAGS}" - LDFLAGS="${LIGHTSTORM_CFLAGS}" rake all --verbose + BUILD_COMMAND + ${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CPP=${CMAKE_CXX_COMPILER} + CFLAGS="${LIGHTSTORM_CFLAGS}" LDFLAGS="${LIGHTSTORM_CFLAGS}" rake all + --verbose BUILD_IN_SOURCE ON INSTALL_COMMAND "" BUILD_BYPRODUCTS ${MRUBY_STATIC} ${MRUBY_BINARY} ${MRBC_BINARY} diff --git a/lib/conversion/c_conversion.cpp b/lib/conversion/c_conversion.cpp index ae89158..5c6deff 100644 --- a/lib/conversion/c_conversion.cpp +++ b/lib/conversion/c_conversion.cpp @@ -1,5 +1,6 @@ #include "lightstorm/conversion/conversion.h" #include "lightstorm/dialect/rite.h" +#include #include #include #include @@ -55,7 +56,7 @@ static std::string cCompatibleSymName(const std::string &sym) { std::string s; std::stringstream ss(s); for (auto c : sym) { - if (isalpha(c) || isnumber(c)) { + if (isalpha(c) || isdigit(c)) { ss << c; continue; } diff --git a/lib/runtime/CMakeLists.txt b/lib/runtime/CMakeLists.txt index 562cbc6..e6de777 100644 --- a/lib/runtime/CMakeLists.txt +++ b/lib/runtime/CMakeLists.txt @@ -6,4 +6,5 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/third_party/mruby/build/host/include) target_compile_options(lightstorm_runtime_main PRIVATE ${LIGHTSTORM_CFLAGS}) target_link_options(lightstorm_runtime_main PRIVATE ${LIGHTSTORM_CFLAGS}) +target_link_libraries(lightstorm_runtime_main PUBLIC m) add_dependencies(lightstorm_runtime_main mruby_static) diff --git a/tests/benchmarks/CMakeLists.txt b/tests/benchmarks/CMakeLists.txt index 1bd4982..1bb5fb4 100644 --- a/tests/benchmarks/CMakeLists.txt +++ b/tests/benchmarks/CMakeLists.txt @@ -13,7 +13,7 @@ function(add_bench_executable ruby) PRIVATE ${CMAKE_SOURCE_DIR}/third_party/mruby/include ${CMAKE_SOURCE_DIR}/third_party/mruby/build/host/include) target_compile_options(${target_name} PRIVATE -g) - target_link_libraries(${target_name} PRIVATE mruby_static) + target_link_libraries(${target_name} PRIVATE mruby_static m) add_dependencies(${target_name} mruby_static) endfunction()