mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builder, pref: use i686-w64-mingw32-gcc for cross compiling 32bit windows apps with v -m32 -os windows hw.v
This commit is contained in:
parent
48c295150f
commit
5905590e78
@ -840,7 +840,7 @@ fn (mut c Builder) cc_windows_cross() {
|
|||||||
all_args << args
|
all_args << args
|
||||||
all_args << '-municode'
|
all_args << '-municode'
|
||||||
c.dump_c_options(all_args)
|
c.dump_c_options(all_args)
|
||||||
mut cmd := pref.vcross_compiler_name(pref.cc_to_windows) + ' ' + all_args.join(' ')
|
mut cmd := c.pref.vcross_compiler_name() + ' ' + all_args.join(' ')
|
||||||
// cmd := 'clang -o $obj_name -w $include -m32 -c -target x86_64-win32 ${pref.default_module_path}/$c.out_name_c'
|
// cmd := 'clang -o $obj_name -w $include -m32 -c -target x86_64-win32 ${pref.default_module_path}/$c.out_name_c'
|
||||||
if c.pref.is_verbose || c.pref.show_cc {
|
if c.pref.is_verbose || c.pref.show_cc {
|
||||||
println(cmd)
|
println(cmd)
|
||||||
|
@ -148,29 +148,18 @@ pub fn (mut p Preferences) fill_with_defaults() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const cc_to_windows = 'x86_64-w64-mingw32-gcc'
|
|
||||||
|
|
||||||
pub const cc_to_linux = 'clang'
|
|
||||||
|
|
||||||
fn (mut p Preferences) find_cc_if_cross_compiling() {
|
fn (mut p Preferences) find_cc_if_cross_compiling() {
|
||||||
if p.os == .windows {
|
if p.os == get_host_os() {
|
||||||
$if !windows {
|
return
|
||||||
// Allow for explicit overrides like `v -showcc -cc msvc -os windows file.v`,
|
|
||||||
// so that the flag passing can be debugged on other OSes too, not only
|
|
||||||
// on windows (building will stop later, when -showcc already could display all
|
|
||||||
// options).
|
|
||||||
if p.ccompiler != 'msvc' {
|
|
||||||
// Cross compiling to Windows
|
|
||||||
p.ccompiler = vcross_compiler_name(pref.cc_to_windows)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if p.os == .linux {
|
if p.os == .windows && p.ccompiler == 'msvc' {
|
||||||
$if !linux {
|
// Allow for explicit overrides like `v -showcc -cc msvc -os windows file.v`,
|
||||||
// Cross compiling to Linux
|
// this makes flag passing more easily debuggable on other OSes too, not only
|
||||||
p.ccompiler = vcross_compiler_name(pref.cc_to_linux)
|
// on windows (building will stop later, when -showcc already could display all
|
||||||
}
|
// options).
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
p.ccompiler = p.vcross_compiler_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut p Preferences) try_to_use_tcc_by_default() {
|
fn (mut p Preferences) try_to_use_tcc_by_default() {
|
||||||
@ -256,10 +245,22 @@ pub fn vexe_path() string {
|
|||||||
return real_vexe_path
|
return real_vexe_path
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vcross_compiler_name(vccname_default string) string {
|
pub fn (p &Preferences) vcross_compiler_name() string {
|
||||||
vccname := os.getenv('VCROSS_COMPILER_NAME')
|
vccname := os.getenv('VCROSS_COMPILER_NAME')
|
||||||
if vccname != '' {
|
if vccname != '' {
|
||||||
return vccname
|
return vccname
|
||||||
}
|
}
|
||||||
return vccname_default
|
if p.os == .windows {
|
||||||
|
if p.m64 {
|
||||||
|
return 'x86_64-w64-mingw32-gcc'
|
||||||
|
}
|
||||||
|
return 'i686-w64-mingw32-gcc'
|
||||||
|
}
|
||||||
|
if p.os == .linux {
|
||||||
|
return 'clang'
|
||||||
|
}
|
||||||
|
eprintln('Note: V can only cross compile to windows and linux for now by default.')
|
||||||
|
eprintln('It will use `cc` as a cross compiler for now, although that will probably fail.')
|
||||||
|
eprintln('Set `VCROSS_COMPILER_NAME` to the name of your cross compiler, for your target OS: $p.os .')
|
||||||
|
return 'cc'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user