Skip to content

Commit 55a7a94

Browse files
committed
Enable LTO and -march=native
-march=native is only enabled when not cross-compiling
1 parent 82caf8e commit 55a7a94

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Rake::ExtensionTask.new('libsass', gem_spec) do |ext|
1414
# Link C++ stdlib statically when building binary gems.
1515
ext.cross_config_options << '--enable-static-stdlib'
1616

17+
ext.cross_config_options << '--disable-march-native'
18+
1719
ext.cross_compiling do |spec|
1820
spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
1921

ext/extconf.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@
1414

1515
$CXXFLAGS << ' -std=c++11'
1616

17-
# Link stdlib statically when building binary gems.
18-
if enable_config('static-stdlib')
17+
# Set to true when building binary gems
18+
if enable_config('static-stdlib', false)
1919
$LDFLAGS << ' -static-libgcc -static-libstdc++'
2020
end
2121

22+
# Set to false when building binary gems
23+
if enable_config('march-native', true)
24+
$CFLAGS << ' -march=native'
25+
$CXXFLAGS << ' -march=native'
26+
end
27+
28+
if enable_config('lto', true)
29+
$CFLAGS << ' -flto'
30+
$CXXFLAGS << ' -flto'
31+
$LDFLAGS << ' -flto'
32+
end
33+
2234
# Disable noisy compilation warnings.
2335
$warnflags = ''
2436
$CFLAGS.gsub!(/[\s+](-ansi|-std=[^\s]+)/, '')

0 commit comments

Comments
 (0)