diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 7fadc6da78..37bd18cde2 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -347,7 +347,11 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { if v.pref.os == .macos { ccoptions.post_args << '-mmacosx-version-min=10.7' } else if v.pref.os == .ios { - ccoptions.post_args << '-miphoneos-version-min=10.0' + if v.pref.is_ios_simulator { + ccoptions.post_args << '-miphonesimulator-version-min=10.0' + } else { + ccoptions.post_args << '-miphoneos-version-min=10.0' + } } else if v.pref.os == .windows { ccoptions.post_args << '-municode' } diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 6dd5c732bb..a2817675b4 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -652,7 +652,9 @@ pub fn (mut g Gen) init() { g.cheaders.writeln('#include ') } else { g.cheaders.writeln(get_guarded_include_text('', 'The C compiler can not find . Please install build-essentials')) // int64_t etc - // g.cheaders.writeln(get_guarded_include_text('', 'The C compiler can not find . Please install build-essentials')) // bool, true, false + if g.pref.os == .ios { + g.cheaders.writeln(get_guarded_include_text('', 'The C compiler can not find . Please install build-essentials')) // bool, true, false + } g.cheaders.writeln(get_guarded_include_text('', 'The C compiler can not find . Please install build-essentials')) // size_t, ptrdiff_t } } diff --git a/vlib/v/pref/default.v b/vlib/v/pref/default.v index 8e101fc24c..38b1663f4c 100644 --- a/vlib/v/pref/default.v +++ b/vlib/v/pref/default.v @@ -219,11 +219,14 @@ pub fn (mut p Preferences) default_c_compiler() { ios_sdk_path_res := os.execute_or_exit('xcrun --sdk $ios_sdk --show-sdk-path') mut isysroot := ios_sdk_path_res.output.replace('\n', '') arch := if p.is_ios_simulator { - '-arch x86_64' + '-arch x86_64 -arch arm64' } else { '-arch armv7 -arch armv7s -arch arm64' } - p.ccompiler = 'xcrun --sdk iphoneos clang -isysroot $isysroot $arch' + // On macOS, /usr/bin/cc is a hardlink/wrapper for xcrun. clang on darwin hosts + // will automatically change the build target based off of the selected sdk, making xcrun -sdk iphoneos pointless + p.ccompiler = '/usr/bin/cc' + p.cflags = '-isysroot $isysroot $arch' + p.cflags return } }