pref, builder: make ./v -gc none -os freebsd examples/hello_world.v work on linux too

This commit is contained in:
Delyan Angelov 2024-05-23 09:29:02 +03:00
parent b7efbca8b6
commit 956a5c00c8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 19 additions and 5 deletions

View File

@ -877,7 +877,7 @@ fn (mut b Builder) cc_freebsd_cross() {
cc_args << '-c "${b.out_name_c}"'
cc_args << libs
b.dump_c_options(cc_args)
mut cc_name := 'cc'
mut cc_name := b.pref.vcross_compiler_name()
mut out_name := b.pref.out_name
$if windows {
cc_name = 'clang.exe'
@ -901,10 +901,7 @@ fn (mut b Builder) cc_freebsd_cross() {
// -ldl
b.dump_c_options(linker_args)
// mut ldlld := '${sysroot}/ld.lld'
mut ldlld := '/opt/homebrew/opt/llvm/bin/ld.lld'
$if windows {
ldlld = 'ld.lld.exe'
}
mut ldlld := b.pref.vcross_linker_name()
linker_cmd := '${b.quote_compiler_name(ldlld)} ' + linker_args.join(' ')
// s = s.replace('SYSROOT', sysroot) // TODO: $ inter bug
// s = s.replace('-o hi', '-o ' + c.pref.out_name)

View File

@ -306,12 +306,29 @@ pub fn vexe_path() string {
return real_vexe_path
}
pub fn (p &Preferences) vcross_linker_name() string {
vlname := os.getenv('VCROSS_LINKER_NAME')
if vlname != '' {
return vlname
}
$if macos {
return '/opt/homebrew/opt/llvm/bin/ld.lld'
}
$if windows {
return 'ld.lld.exe'
}
return 'ld.lld'
}
pub fn (p &Preferences) vcross_compiler_name() string {
vccname := os.getenv('VCROSS_COMPILER_NAME')
if vccname != '' {
return vccname
}
if p.os == .windows {
if p.os == .freebsd {
return 'clang'
}
if p.m64 {
return 'x86_64-w64-mingw32-gcc'
}