Skip to content

Commit 5cd41d0

Browse files
authored
Avoid native arch when building for pypi (#387)
1 parent 5d36cb9 commit 5cd41d0

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.github/workflows/pypi.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ jobs:
8787
python -m pip install build wheel setuptools pybind11-stubgen auditwheel
8888
8989
- name: Build wheel
90+
env:
91+
CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF"
9092
run: |
9193
rm -rf dist wheelhouse
9294
python -m build --wheel
@@ -140,6 +142,8 @@ jobs:
140142
echo "_PYTHON_HOST_PLATFORM=macosx-$(sw_vers -productVersion | cut -d. -f1)-$(uname -m)" >> $GITHUB_ENV
141143
142144
- name: Build wheel
145+
env:
146+
CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF"
143147
run: python -m build --wheel
144148

145149
- name: Repair wheel (bundle libraries)
@@ -188,6 +192,8 @@ jobs:
188192
python -m pip install build wheel setuptools pybind11-stubgen
189193
190194
- name: Build wheel
195+
env:
196+
CMAKE_ARGS: "-DDSF_OPTIMIZE_ARCH=OFF"
191197
run: python -m build --wheel
192198

193199
- name: Upload wheels as artifacts

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ option(DSF_EXAMPLES "Build DSF examples" OFF)
2222
option(DSF_BENCHMARKS "Build DSF benchmarks" OFF)
2323
option(DSF_BUILD_PIC "Build DSF with position-independent code" OFF)
2424
option(BUILD_PYTHON_BINDINGS "Build Python bindings" OFF)
25+
option(DSF_OPTIMIZE_ARCH "Optimize for native architecture" ON)
2526

2627
# If CMAKE_BUILD_TYPE not set, default to Debug
2728
if(NOT CMAKE_BUILD_TYPE)
@@ -49,13 +50,19 @@ set(CMAKE_CXX_EXTENSIONS OFF)
4950
# Ensure optimization flags are applied only in Release mode
5051
if(CMAKE_BUILD_TYPE MATCHES "Release")
5152
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
52-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -march=native -flto=auto")
53+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -flto=auto")
54+
if(DSF_OPTIMIZE_ARCH)
55+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
56+
endif()
5357
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
5458
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2")
5559
endif()
5660
elseif(CMAKE_BUILD_TYPE MATCHES "Profile")
5761
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
58-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -march=native -flto=auto -pg")
62+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -flto=auto -pg")
63+
if(DSF_OPTIMIZE_ARCH)
64+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
65+
endif()
5966
endif()
6067
elseif(CMAKE_BUILD_TYPE MATCHES "Coverage")
6168
set(DSF_TESTS ON)

src/dsf/dsf.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
static constexpr uint8_t DSF_VERSION_MAJOR = 4;
88
static constexpr uint8_t DSF_VERSION_MINOR = 5;
9-
static constexpr uint8_t DSF_VERSION_PATCH = 3;
9+
static constexpr uint8_t DSF_VERSION_PATCH = 4;
1010

1111
static auto const DSF_VERSION =
1212
std::format("{}.{}.{}", DSF_VERSION_MAJOR, DSF_VERSION_MINOR, DSF_VERSION_PATCH);

0 commit comments

Comments
 (0)