From 11ee2b6409b49f4c257a4e9a067a6dc7faebd187 Mon Sep 17 00:00:00 2001 From: Haren S <12570877+harens@users.noreply.github.com> Date: Mon, 25 Apr 2022 06:17:00 +0100 Subject: [PATCH] builder: improve macOS 10.5 and PPC support (#14152) --- vlib/v/builder/cc.v | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index c2b86e5dba..07a6294fa3 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -206,6 +206,14 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { if v.pref.os == .macos && os.exists('/opt/procursus') { ccoptions.linker_flags << '-Wl,-rpath,/opt/procursus/lib' } + mut user_darwin_version := 999_999_999 + mut user_darwin_ppc := false + $if macos { + user_darwin_version = os.uname().release.split('.')[0].int() + if os.uname().machine == 'Power Macintosh' { + user_darwin_ppc = true + } + } ccoptions.debug_mode = v.pref.is_debug ccoptions.guessed_compiler = v.pref.ccompiler if ccoptions.guessed_compiler == 'cc' && v.pref.is_prod { @@ -252,7 +260,10 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { } if ccoptions.is_cc_gcc { if ccoptions.debug_mode { - debug_options = ['-g', '-no-pie'] + debug_options = ['-g'] + if user_darwin_version > 9 { + debug_options << '-no-pie' + } } optimization_options = ['-O3', '-fno-strict-aliasing', '-flto'] } @@ -334,7 +345,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { } // macOS code can include objective C TODO remove once objective C is replaced with C if v.pref.os == .macos || v.pref.os == .ios { - if !ccoptions.is_cc_tcc { + if !ccoptions.is_cc_tcc && !user_darwin_ppc { ccoptions.source_args << '-x objective-c' } }