v.builder: fix iOS compilation from non-macOS, allow -cc to override the default cross compiler (#13866)
parent
3e69d3813b
commit
093994655c
|
@ -526,17 +526,7 @@ pub fn (mut v Builder) cc() {
|
||||||
// try to compile with the choosen compiler
|
// try to compile with the choosen compiler
|
||||||
// if compilation fails, retry again with another
|
// if compilation fails, retry again with another
|
||||||
mut ccompiler := v.pref.ccompiler
|
mut ccompiler := v.pref.ccompiler
|
||||||
if v.pref.os == .ios {
|
if v.pref.os == .wasm32 {
|
||||||
ios_sdk := if v.pref.is_ios_simulator { 'iphonesimulator' } else { 'iphoneos' }
|
|
||||||
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 v.pref.is_ios_simulator {
|
|
||||||
'-arch x86_64'
|
|
||||||
} else {
|
|
||||||
'-arch armv7 -arch armv7s -arch arm64'
|
|
||||||
}
|
|
||||||
ccompiler = 'xcrun --sdk iphoneos clang -isysroot $isysroot $arch'
|
|
||||||
} else if v.pref.os == .wasm32 {
|
|
||||||
ccompiler = 'clang'
|
ccompiler = 'clang'
|
||||||
}
|
}
|
||||||
v.setup_ccompiler_options(ccompiler)
|
v.setup_ccompiler_options(ccompiler)
|
||||||
|
@ -622,7 +612,7 @@ pub fn (mut v Builder) cc() {
|
||||||
}
|
}
|
||||||
if v.pref.retry_compilation {
|
if v.pref.retry_compilation {
|
||||||
tcc_output = res
|
tcc_output = res
|
||||||
v.pref.ccompiler = pref.default_c_compiler()
|
v.pref.default_c_compiler()
|
||||||
if v.pref.is_verbose {
|
if v.pref.is_verbose {
|
||||||
eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...')
|
eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...')
|
||||||
}
|
}
|
||||||
|
|
|
@ -652,6 +652,7 @@ pub fn (mut g Gen) init() {
|
||||||
g.cheaders.writeln('#include <stddef.h>')
|
g.cheaders.writeln('#include <stddef.h>')
|
||||||
} else {
|
} 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('<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
|
||||||
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
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ pub fn (mut p Preferences) fill_with_defaults() {
|
||||||
//
|
//
|
||||||
p.try_to_use_tcc_by_default()
|
p.try_to_use_tcc_by_default()
|
||||||
if p.ccompiler == '' {
|
if p.ccompiler == '' {
|
||||||
p.ccompiler = default_c_compiler()
|
p.default_c_compiler()
|
||||||
}
|
}
|
||||||
p.find_cc_if_cross_compiling()
|
p.find_cc_if_cross_compiling()
|
||||||
p.ccompiler_type = cc_from_string(p.ccompiler)
|
p.ccompiler_type = cc_from_string(p.ccompiler)
|
||||||
|
@ -203,16 +203,32 @@ pub fn default_tcc_compiler() string {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_c_compiler() string {
|
pub fn (mut p Preferences) default_c_compiler() {
|
||||||
// fast_clang := '/usr/local/Cellar/llvm/8.0.0/bin/clang'
|
// fast_clang := '/usr/local/Cellar/llvm/8.0.0/bin/clang'
|
||||||
// if os.exists(fast_clang) {
|
// if os.exists(fast_clang) {
|
||||||
// return fast_clang
|
// return fast_clang
|
||||||
// }
|
// }
|
||||||
// TODO fix $if after 'string'
|
// TODO fix $if after 'string'
|
||||||
$if windows {
|
$if windows {
|
||||||
return 'gcc'
|
p.ccompiler = 'gcc'
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return 'cc'
|
if p.os == .ios {
|
||||||
|
$if !ios {
|
||||||
|
ios_sdk := if p.is_ios_simulator { 'iphonesimulator' } else { 'iphoneos' }
|
||||||
|
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'
|
||||||
|
} else {
|
||||||
|
'-arch armv7 -arch armv7s -arch arm64'
|
||||||
|
}
|
||||||
|
p.ccompiler = 'xcrun --sdk iphoneos clang -isysroot $isysroot $arch'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.ccompiler = 'cc'
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vexe_path() string {
|
pub fn vexe_path() string {
|
||||||
|
|
Loading…
Reference in New Issue