@@ -1302,58 +1302,6 @@ fn (mut b Builder) cc_linux_cross() {
13021302 verror(cc_res.output)
13031303 return
13041304 }
1305- // Compile extra .c source files (from `#flag @VMODROOT/file.c` etc.)
1306- // separately for the cross target, and collect the resulting .o files.
1307- mut extra_obj_files := []string{cap: extra_c_sources.len}
1308- for csource in extra_c_sources {
1309- extra_obj := csource + ' .o'
1310- mut extra_cc_args := []string{cap: 10}
1311- extra_cc_args << ' - w'
1312- extra_cc_args << ' - fPIC'
1313- extra_cc_args << ' - target x86_64 - linux- gnu'
1314- extra_cc_args << defines
1315- extra_cc_args << conly_flags
1316- extra_cc_args << ' - I ${os.quoted_path ('${sysroot} /include' )} '
1317- extra_cc_args << ' - o ${os.quoted_path (extra_obj)}'
1318- extra_cc_args << ' - c ${os.quoted_path (csource)}'
1319- extra_cmd := ' ${b.quote_compiler_name (cc_name)} ' + extra_cc_args.join(' ')
1320- if b.pref.show_cc {
1321- println(extra_cmd)
1322- }
1323- extra_res := os.execute(extra_cmd)
1324- if extra_res.exit_code != 0 {
1325- println(' Cross compilation for Linux failed (compiling ${csource}).')
1326- verror(extra_res.output)
1327- return
1328- }
1329- extra_obj_files << os.quoted_path(extra_obj)
1330- }
1331- // For libraries that only exist as static .a in the sysroot (e.g. libpq.a),
1332- // create shared library stubs so the linker produces a dynamically linked binary
1333- // instead of pulling in incomplete static archives with missing internal deps.
1334- lib_search_paths := [
1335- os.join_path(sysroot, ' usr ', ' lib', ' x86_64 - linux- gnu'),
1336- os.join_path(sysroot, ' lib', ' x86_64 - linux- gnu'),
1337- ]
1338- stubs_dir := os.join_path(os.vtmp_dir(), ' cross_linux_stubs')
1339- os.mkdir_all(stubs_dir) or {}
1340- for lib in libs {
1341- libname := lib.replace(' - l', '')
1342- if libname in ['c ', ' pthread', ' m', ' dl'] {
1343- continue // standard libs, always available
1344- }
1345- has_so := lib_search_paths.any(os.exists(os.join_path(it, ' lib${libname}.so')))
1346- has_a := !has_so && lib_search_paths.any(os.exists(os.join_path(it, ' lib${libname}.a')))
1347- if has_a {
1348- a_path := lib_search_paths.map(os.join_path(it, ' lib${libname}.a')).filter(os.exists(it))[0] or {
1349- continue
1350- }
1351- stub_so := os.join_path(stubs_dir, ' lib${libname}.so')
1352- if !os.exists(stub_so) {
1353- b.create_shared_lib_stub(cc_name, a_path, stub_so, sysroot)
1354- }
1355- }
1356- }
13571305 // Compile compiler runtime builtins (provides __udivti3 etc. for 128-bit integer
13581306 // operations used by thirdparty code like mbedtls bignum.c, since the linuxroot
13591307 // sysroot doesn' t include libgcc or compiler- rt).
0 commit comments