1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builder,cgen: iOS fixes (#13883)

This commit is contained in:
Cameron Katri 2022-03-31 04:51:13 -04:00 committed by GitHub
parent 4222fd0862
commit b15240185e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -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'
}

View File

@ -652,7 +652,9 @@ pub fn (mut g Gen) init() {
g.cheaders.writeln('#include <stddef.h>')
} else {
g.cheaders.writeln(get_guarded_include_text('<inttypes.h>', 'The C compiler can not find <inttypes.h>. Please install build-essentials')) // int64_t etc
// g.cheaders.writeln(get_guarded_include_text('<stdbool.h>', 'The C compiler can not find <stdbool.h>. Please install build-essentials')) // bool, true, false
if g.pref.os == .ios {
g.cheaders.writeln(get_guarded_include_text('<stdbool.h>', 'The C compiler can not find <stdbool.h>. Please install build-essentials')) // bool, true, false
}
g.cheaders.writeln(get_guarded_include_text('<stddef.h>', 'The C compiler can not find <stddef.h>. Please install build-essentials')) // size_t, ptrdiff_t
}
}

View File

@ -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
}
}