Skip to content

Commit 8452e70

Browse files
committed
fix: portable build of native extensions to avoid SIGILL
- replaced -march=native with -march=x86-64 -mtune=generic by default in extconf.rb and terrain_downsample_extconf.rb - added TPC_EXT_NATIVE=1 env to enable -march=native -mtune=native - added TPC_EXT_LTO=1 env to enable -flto - updated lerc_extension docs (en/ru) in Optimizations section
1 parent 09172b7 commit 8452e70

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/docs/en/lerc_extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ The extension is integrated into the main tile caching service (`config.ru`) and
145145
### Optimizations
146146
- Memory pre-allocation (`reserve()`)
147147
- Direct pointer arithmetic in critical loops
148-
- Aggressive compiler flags (`-O3`, `-march=native`, `-flto`)
148+
- Compiler flags (`-O3`; optional arch/LTO flags depending on build)
149149
- RTTI disabled for size reduction
150150

151151
### Limitations

src/docs/ru/lerc_extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ LercFFI.lerc_to_mapbox_png(lerc_data) # => png_data
145145
### Оптимизации
146146
- Предварительная аллокация памяти (`reserve()`)
147147
- Прямая арифметика указателей в критических циклах
148-
- Агрессивные флаги компилятора (`-O3`, `-march=native`, `-flto`)
148+
- Флаги компилятора (`-O3`; опциональные arch/LTO зависят от сборки)
149149
- Отключение RTTI для уменьшения размера
150150

151151
### Ограничения

src/ext/extconf.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
require "mkmf"
22

3-
$CXXFLAGS += " -std=c++23 -O3 -march=native -mtune=native -flto -Wno-unused-function"
3+
native = ENV["TPC_EXT_NATIVE"] == "1"
4+
lto = ENV["TPC_EXT_LTO"] == "1"
5+
6+
arch_flags =
7+
if native
8+
" -march=native -mtune=native"
9+
else
10+
" -march=x86-64 -mtune=generic"
11+
end
12+
13+
$CXXFLAGS += " -std=c++23 -O3#{arch_flags}#{lto ? ' -flto' : ''} -Wno-unused-function"
414
$CXXFLAGS += " -Wall -Wextra -Wpedantic"
515
$CXXFLAGS += " -fno-rtti"
616
$CPPFLAGS += " -I/usr/local/include"

src/ext/terrain_downsample_extconf.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
require "mkmf"
22

3-
$CXXFLAGS += " -std=c++23 -O3 -march=native -mtune=native -flto -Wno-unused-function"
3+
native = ENV["TPC_EXT_NATIVE"] == "1"
4+
lto = ENV["TPC_EXT_LTO"] == "1"
5+
6+
arch_flags =
7+
if native
8+
" -march=native -mtune=native"
9+
else
10+
" -march=x86-64 -mtune=generic"
11+
end
12+
13+
$CXXFLAGS += " -std=c++23 -O3#{arch_flags}#{lto ? ' -flto' : ''} -Wno-unused-function"
414
$CXXFLAGS += " -Wall -Wextra -Wpedantic"
515
$CXXFLAGS += " -fno-rtti"
616
$CPPFLAGS += " -I/usr/local/include"

0 commit comments

Comments
 (0)