Skip to content

Commit

Permalink
Enable LTO and -march=native
Browse files Browse the repository at this point in the history
-march=native is only enabled when not cross-compiling
  • Loading branch information
glebm committed May 29, 2019
1 parent 82caf8e commit 55a7a94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Rake::ExtensionTask.new('libsass', gem_spec) do |ext|
# Link C++ stdlib statically when building binary gems.
ext.cross_config_options << '--enable-static-stdlib'

ext.cross_config_options << '--disable-march-native'

ext.cross_compiling do |spec|
spec.files.reject! { |path| File.fnmatch?('ext/*', path) }

Expand Down
16 changes: 14 additions & 2 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@

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

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

# Set to false when building binary gems
if enable_config('march-native', true)
$CFLAGS << ' -march=native'
$CXXFLAGS << ' -march=native'
end

if enable_config('lto', true)
$CFLAGS << ' -flto'
$CXXFLAGS << ' -flto'
$LDFLAGS << ' -flto'
end

# Disable noisy compilation warnings.
$warnflags = ''
$CFLAGS.gsub!(/[\s+](-ansi|-std=[^\s]+)/, '')
Expand Down

0 comments on commit 55a7a94

Please sign in to comment.