Skip to content

Commit

Permalink
c flags???
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Jan 31, 2025
1 parent 11c9df1 commit 2b1b686
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 40 deletions.
14 changes: 6 additions & 8 deletions .github/actions/setup_base/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ runs:
ccache: ${{ startsWith(inputs.os, 'windows') || startsWith(inputs.os, 'ubuntu') }}
vcvarsall: ${{ startsWith(inputs.os, 'windows') }}

# https://github.com/actions/runner-images/issues/10035
- name: Use the Command Line Tools
shell: bash
if: ${{ startsWith(inputs.os, 'macos') && inputs.arch == 'x86_64' }}
run: |
sudo xcode-select -s /Library/Developer/CommandLineTools
- name: "Set CC/CXX"
shell: bash
run: |
Expand Down Expand Up @@ -175,12 +168,17 @@ runs:
ccache -z
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
echo "CMAKE_MAKE_PROGRAM=Ninja" >> $GITHUB_ENV
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
echo "Python3_EXECUTABLE=$(which $python3_command)" >> $GITHUB_ENV
if [[ "${{ inputs.arch }}" != "wasm32-wasi" ]]; then
if [[ "${{ inputs.os }}" == "ubuntu" ]] || [[ "${{ inputs.os }}" == "windows" ]]; then
echo "CMAKE_EXE_LINKER_FLAGS_INIT=-fuse-ld=lld" >> $GITHUB_ENV
echo "CMAKE_SHARED_LINKER_FLAGS_INIT=-fuse-ld=lld" >> $GITHUB_ENV
echo "CMAKE_MODULE_LINKER_FLAGS_INIT=-fuse-ld=lld" >> $GITHUB_ENV
fi
if [[ "${{ matrix.os }}" == "macos" ]]; then
echo MACOSX_DEPLOYMENT_TARGET=10.14 >> $GITHUB_ENV
fi
5 changes: 5 additions & 0 deletions .github/workflows/build_llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ jobs:
# double nested so that upload artifacts uploads a folder
export LLVM_INSTALL_DIR="$PWD/llvm-install/llvm-install"
# because macos-13 is broken so we need to cross-compile from macos-14, which is an arm runner
if [[ "${{ matrix.arch }}" == "macos_arm64" ]]; then
export CMAKE_OSX_ARCHITECTURES="x86_64;arm64"
fi
ccache -z
$python3_command -m pip install -r third_party/llvm-project/mlir/python/requirements.txt
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/build_test_release_eudsl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,6 @@ jobs:
echo "PIP_FIND_LINKS=$PWD/wheelhouse" >> $GITHUB_ENV
fi
# these have to match the deployment targets of the LLVM build runners
# ld: warning: object file (libLLVMTableGen.a[3](Error.cpp.o)) was built for newer 'macOS' version (13.7) than being linked (10.13)
if [[ "${{ matrix.runs-on }}" == "macos-14" ]]; then
echo MACOSX_DEPLOYMENT_TARGET=14.0 >> $GITHUB_ENV
fi
# https://github.com/wjakob/nanobind/issues/433
# i don't know why i need this here but the llvm build doesn't?
if [[ "${{ matrix.runs-on }}" == "macos-13" ]]; then
echo CMAKE_CXX_FLAGS="-fno-aligned-allocation" >> $GITHUB_ENV
fi
$python3_command -m pip install cibuildwheel
if [[ "${{ matrix.os }}" == "ubuntu" ]] && [[ "${{ matrix.arch }}" == "aarch64" ]]; then
sudo apt-get install libarchive-dev antlr libxml2-dev libxslt-dev libcurl4-openssl-dev
Expand Down Expand Up @@ -242,17 +231,17 @@ jobs:
strategy:
fail-fast: false
matrix:
runs-on: ["ubuntu-22.04", "ubuntu-22.04-arm", "macos-13", "macos-14", "windows-2019"]
runs-on: ["ubuntu-22.04", "ubuntu-22.04-arm", "macos-14", "windows-2019"]
python-version: [
# "3.9", "3.10", "3.11",
"3.12"
"3.9", "3.10", "3.11",
"3.12", "3.13"
]
include: [
{runs-on: "ubuntu-22.04", name: "ubuntu_x86_64", os: "ubuntu"},
{runs-on: "ubuntu-22.04-arm", name: "ubuntu_aarch64", os: "ubuntu"},
{runs-on: "windows-2019", name: "windows_x86_64", os: "windows"},
{runs-on: "macos-14", name: "macos_arm64", os: "macos"},
{runs-on: "macos-13", name: "macos_x86_64", os: "macos"}
# {runs-on: "macos-13", name: "macos_x86_64", os: "macos"}
]

runs-on: ${{ matrix.runs-on }}
Expand Down Expand Up @@ -366,7 +355,6 @@ jobs:
"ubuntu-22.04",
"ubuntu-22.04-arm",
"macos-14",
"macos-13",
"windows-2019"
]
python-version: [
Expand All @@ -378,7 +366,7 @@ jobs:
{runs-on: "ubuntu-22.04-arm", name: "ubuntu_aarch64", os: "ubuntu"},
{runs-on: "windows-2019", name: "windows_x86_64", os: "windows"},
{runs-on: "macos-14", name: "macos_arm64", os: "macos"},
{runs-on: "macos-13", name: "macos_x86_64", os: "macos"}
# {runs-on: "macos-13", name: "macos_x86_64", os: "macos"}
]

runs-on: ${{ matrix.runs-on }}
Expand Down Expand Up @@ -439,7 +427,7 @@ jobs:
"ubuntu_x86_64",
"ubuntu_aarch64",
"macos_arm64",
"macos_x86_64",
# "macos_x86_64",
"windows_x86_64"
]

Expand Down
10 changes: 8 additions & 2 deletions projects/eudsl-llvmpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ include_directories("${EUDSLLLVM_BINARY_DIR}/generated")
file(GLOB _gen_src CONFIGURE_DEPENDS "${EUDSLLLVM_BINARY_DIR}/generated/*.cpp")

nanobind_add_module(eudslllvm_ext
NB_STATIC
NB_STATIC STABLE_ABI
NB_DOMAIN eudslllvm
src/eudslllvm_ext.cpp
${_gen_src}
Expand Down Expand Up @@ -155,7 +155,13 @@ set_target_properties(eudslllvm_ext
)

target_compile_options(eudslllvm_ext PRIVATE ${nanobind_options})
target_compile_options(nanobind-static PRIVATE ${nanobind_options})
set(_nanobind_tgt)
if(TARGET nanobind-static)
set(_nanobind_tgt nanobind-static)
elseif(TARGET nanobind-static-abi3)
set(_nanobind_tgt nanobind-static-abi3)
endif()
target_compile_options(${_nanobind_tgt} PRIVATE ${nanobind_options})

# note WORKING_DIRECTORY
set(NB_STUBGEN_CMD "${Python_EXECUTABLE}" "-m" "nanobind.stubgen"
Expand Down
12 changes: 11 additions & 1 deletion projects/eudsl-llvmpy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ Homepage = "https://github.com/llvm/eudsl"

[build-system]
requires = [
"ninja",
"scikit-build-core==0.10.7",
"nanobind==2.4.0",
"typing_extensions==4.12.2",
"litgen @ git+https://github.com/pthom/litgen@f5d154c6f7679e755baa1047563d7c340309bc00",
"eudsl-tblgen"
"eudsl-tblgen",
]
build-backend = "scikit_build_core.build"

Expand All @@ -25,6 +26,7 @@ minimum-version = "0.4"
build-dir = "build/{wheel_tag}"
cmake.source-dir = "."
wheel.packages = ["src/llvm"]
wheel.py-api = "cp312"
editable.mode = "inplace"
editable.verbose = true
editable.rebuild = false
Expand All @@ -35,6 +37,9 @@ CMAKE_C_FLAGS = { env = "CMAKE_C_FLAGS", default = "" }
CMAKE_CXX_FLAGS = { env = "CMAKE_CXX_FLAGS", default = "" }
CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" }
CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" }
CMAKE_EXE_LINKER_FLAGS_INIT = { env = "CMAKE_EXE_LINKER_FLAGS_INIT", default = "" }
CMAKE_SHARED_LINKER_FLAGS_INIT = { env = "CMAKE_SHARED_LINKER_FLAGS_INIT", default = "" }
CMAKE_MODULE_LINKER_FLAGS_INIT = { env = "CMAKE_MODULE_LINKER_FLAGS_INIT", default = "" }
CMAKE_C_VISIBILITY_PRESET = "hidden"
CMAKE_CXX_VISIBILITY_PRESET = "hidden"
CMAKE_VISIBILITY_INLINES_HIDDEN = "ON"
Expand Down Expand Up @@ -80,3 +85,8 @@ before-all = [
]
# synchronize TZ with host so ccache files have correct timestamp
container-engine = { name = "docker", create-args = ["-v", "/etc/timezone:/etc/timezone:ro", "-v", "/etc/localtime:/etc/localtime:ro"] }

[tool.cibuildwheel.macos]
before-build = [
"ccache -z"
]
3 changes: 3 additions & 0 deletions projects/eudsl-nbgen/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ CMAKE_C_FLAGS = { env = "CMAKE_C_FLAGS", default = "" }
CMAKE_CXX_FLAGS = { env = "CMAKE_CXX_FLAGS", default = "" }
CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" }
CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" }
CMAKE_EXE_LINKER_FLAGS_INIT = { env = "CMAKE_EXE_LINKER_FLAGS_INIT", default = "" }
CMAKE_SHARED_LINKER_FLAGS_INIT = { env = "CMAKE_SHARED_LINKER_FLAGS_INIT", default = "" }
CMAKE_MODULE_LINKER_FLAGS_INIT = { env = "CMAKE_MODULE_LINKER_FLAGS_INIT", default = "" }
CMAKE_C_VISIBILITY_PRESET = "hidden"
CMAKE_CXX_VISIBILITY_PRESET = "hidden"
CMAKE_VISIBILITY_INLINES_HIDDEN = "ON"
Expand Down
10 changes: 8 additions & 2 deletions projects/eudsl-py/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ eudsl_nbgen(EUDSLGen_tosa
#)

nanobind_add_module(eudslpy_ext
NB_STATIC
NB_STATIC STABLE_ABI
NB_DOMAIN eudsl
src/eudslpy_ext.cpp
)
Expand Down Expand Up @@ -427,7 +427,13 @@ set_install_rpath_origin(eudslpy_ext)
install(IMPORTED_RUNTIME_ARTIFACTS MLIR LLVM LIBRARY DESTINATION eudsl)

target_compile_options(eudslpy_ext PRIVATE ${nanobind_options})
target_compile_options(nanobind-static PRIVATE ${nanobind_options})
set(_nanobind_tgt)
if(TARGET nanobind-static)
set(_nanobind_tgt nanobind-static)
elseif(TARGET nanobind-static-abi3)
set(_nanobind_tgt nanobind-static-abi3)
endif()
target_compile_options(${_nanobind_tgt} PRIVATE ${nanobind_options})

# note WORKING_DIRECTORY
set(NB_STUBGEN_CMD "${Python_EXECUTABLE}" "-m" "nanobind.stubgen"
Expand Down
3 changes: 3 additions & 0 deletions projects/eudsl-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ CMAKE_C_FLAGS = { env = "CMAKE_C_FLAGS", default = "" }
CMAKE_CXX_FLAGS = { env = "CMAKE_CXX_FLAGS", default = "" }
CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" }
CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" }
CMAKE_EXE_LINKER_FLAGS_INIT = { env = "CMAKE_EXE_LINKER_FLAGS_INIT", default = "" }
CMAKE_SHARED_LINKER_FLAGS_INIT = { env = "CMAKE_SHARED_LINKER_FLAGS_INIT", default = "" }
CMAKE_MODULE_LINKER_FLAGS_INIT = { env = "CMAKE_MODULE_LINKER_FLAGS_INIT", default = "" }
CMAKE_C_VISIBILITY_PRESET = "hidden"
CMAKE_CXX_VISIBILITY_PRESET = "hidden"
CMAKE_VISIBILITY_INLINES_HIDDEN = "ON"
Expand Down
17 changes: 15 additions & 2 deletions projects/eudsl-tblgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,25 @@ nanobind_add_module(eudsl_tblgen_ext NB_STATIC STABLE_ABI
)
target_link_libraries(eudsl_tblgen_ext
PRIVATE LLVMTableGenCommon LLVMTableGen LLVMCore)
target_compile_options(eudsl_tblgen_ext
PUBLIC
set(nanobind_options
-Wno-cast-qual
-Wno-deprecated-literal-operator
-Wno-covered-switch-default
-Wno-nested-anon-types
-Wno-zero-length-array
-Wno-c++98-compat-extra-semi
-Wno-c++20-extensions
$<$<PLATFORM_ID:Linux>:-fexceptions -frtti>
$<$<PLATFORM_ID:Darwin>:-fexceptions -frtti>
$<$<PLATFORM_ID:Windows>:/EHsc /GR>)
target_compile_options(eudsl_tblgen_ext PRIVATE ${nanobind_options})
set(_nanobind_tgt)
if(TARGET nanobind-static)
set(_nanobind_tgt nanobind-static)
elseif(TARGET nanobind-static-abi3)
set(_nanobind_tgt nanobind-static-abi3)
endif()
target_compile_options(${_nanobind_tgt} PRIVATE ${nanobind_options})

# note WORKING_DIRECTORY
set(NB_STUBGEN_CMD "${Python_EXECUTABLE}" "-m" "nanobind.stubgen"
Expand Down
27 changes: 20 additions & 7 deletions projects/eudsl-tblgen/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ minimum-version = "0.4"
build-dir = "build/{wheel_tag}"
cmake.source-dir = "."
wheel.packages = ["src/eudsl_tblgen"]
wheel.py-api = "cp312"

[tool.scikit-build.cmake.define]
LLVM_DIR = { env = "LLVM_DIR", default = "EMPTY" }
CMAKE_CXX_VISIBILITY_PRESET = "hidden"
CMAKE_PREFIX_PATH = { env = "CMAKE_PREFIX_PATH", default = "" }
CMAKE_C_FLAGS = { env = "CMAKE_C_FLAGS", default = "" }
CMAKE_CXX_FLAGS = { env = "CMAKE_CXX_FLAGS", default = "" }
CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" }
CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" }
CMAKE_PREFIX_PATH = { env = "CMAKE_PREFIX_PATH", default = "" }
CMAKE_EXE_LINKER_FLAGS_INIT = { env = "CMAKE_EXE_LINKER_FLAGS_INIT", default = "" }
CMAKE_SHARED_LINKER_FLAGS_INIT = { env = "CMAKE_SHARED_LINKER_FLAGS_INIT", default = "" }
CMAKE_MODULE_LINKER_FLAGS_INIT = { env = "CMAKE_MODULE_LINKER_FLAGS_INIT", default = "" }
CMAKE_C_VISIBILITY_PRESET = "hidden"
CMAKE_CXX_VISIBILITY_PRESET = "hidden"
CMAKE_VISIBILITY_INLINES_HIDDEN = "ON"
CMAKE_VERBOSE_MAKEFILE = "ON"
LLVM_DIR = { env = "LLVM_DIR", default = "EMPTY" }
LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN = "ON"

[tool.cibuildwheel]
Expand All @@ -36,19 +45,23 @@ archs = ["auto64"]
manylinux-x86_64-image = "manylinux_2_28"
manylinux-aarch64-image = "quay.io/pypa/manylinux_2_34_aarch64"
environment-pass = [
"LLVM_DIR",
"CMAKE_GENERATOR",
"CMAKE_PREFIX_PATH",
"CMAKE_C_FLAGS",
"CMAKE_CXX_FLAGS",
"CMAKE_C_COMPILER_LAUNCHER",
"CMAKE_CXX_COMPILER_LAUNCHER",
"CMAKE_GENERATOR",
"CC",
"CXX",
"LLVM_DIR",
# ccache
"CCACHE_DIR",
"CCACHE_MAXSIZE=700M",
"CCACHE_SLOPPINESS",
"CCACHE_CPP2",
"CCACHE_UMASK",
"CMAKE_C_COMPILER_LAUNCHER",
"CMAKE_CXX_COMPILER_LAUNCHER"
"CCACHE_NOHASHDIR",
"PIP_FIND_LINKS",
]
before-build = [
"export CCACHE_DIR=$CCACHE_DIR/$(python -c 'import platform; print(platform.python_version())')",
Expand Down

0 comments on commit 2b1b686

Please sign in to comment.