mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 10:46:39 +00:00
fix(compiling): improve portability of builds
This makes the -march=native CFLAG optional, and disabled by default, but still available through a new --native-march flag. It should make builds more portable between machines, as previously it was very common to get a CPU architecture error on launch if you moved the build to a different machine running a different generation of a Intel CPU. From what I've understood, when using the -march=native CFLAG clang will make as many optimizations possible based on the exact set of CPU instructions available on the specific CPU it's compiling on. In theory this leads to a more optimized build, though I haven't personally noticed any difference. But it also leads to less portable builds, for example builds from a Intel-based 2020 MacBook Pro just crash with a unsupported CPU architecture error when run on a Intel-based 2016 MacBook Pro.
This commit is contained in:
@@ -74,6 +74,7 @@ Options:
|
||||
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
|
||||
--[no-]xwidgets Enable/disable XWidgets if supported (default: enabled)
|
||||
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
||||
--[no-]native-march Enable/disable -march=native CFLAG(default: disabled)
|
||||
--[no-]native-full-aot Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation (default: disabled)
|
||||
--[no-]rsvg Enable/disable SVG image support via librsvg (default: enabled)
|
||||
--no-titlebar Apply no-titlebar patch (default: disabled)
|
||||
|
||||
@@ -267,7 +267,7 @@ class Build
|
||||
"-I#{File.join(gcc_info.root_dir, 'include')}",
|
||||
"-I#{File.join(gcc_info.libgccjit_root_dir, 'include')}",
|
||||
'-O2',
|
||||
'-march=native',
|
||||
(options[:native_march] ? '-march=native' : nil),
|
||||
ENV['CFLAGS']
|
||||
].compact.join(' ')
|
||||
|
||||
@@ -904,6 +904,7 @@ if __FILE__ == $PROGRAM_NAME
|
||||
cli_options = {
|
||||
work_dir: File.expand_path(__dir__),
|
||||
native_full_aot: false,
|
||||
native_march: false,
|
||||
parallel: Etc.nprocessors,
|
||||
rsvg: true,
|
||||
xwidgets: true,
|
||||
@@ -945,6 +946,12 @@ if __FILE__ == $PROGRAM_NAME
|
||||
cli_options[:native_comp] = v
|
||||
end
|
||||
|
||||
opts.on('--[no-]native-march',
|
||||
'Enable/disable -march=native CFLAG' \
|
||||
'(default: disabled)') do |v|
|
||||
cli_options[:native_march] = v
|
||||
end
|
||||
|
||||
opts.on('--[no-]native-full-aot',
|
||||
'Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation ' \
|
||||
'(default: disabled)') do |v|
|
||||
|
||||
Reference in New Issue
Block a user