| 1 | // A single compiler name for build systems such as libtool that independently |
| 2 | // expand CC and its arguments. Repeating musl's specs option makes GCC fail. |
| 3 | module main |
| 4 | |
| 5 | import os |
| 6 | |
| 7 | fn main() { |
| 8 | root := os.getenv('VPAC_MAKEPKG_ROOT') |
| 9 | if !os.is_abs_path(root) { |
| 10 | eprintln('vinix-cc requires an absolute VPAC_MAKEPKG_ROOT') |
| 11 | exit(1) |
| 12 | } |
| 13 | specs := os.join_path(root, 'usr/lib/musl-gcc-sysroot.specs') |
| 14 | if !os.is_file(specs) { |
| 15 | eprintln('vinix-cc: missing installed musl specs at ${specs}') |
| 16 | exit(1) |
| 17 | } |
| 18 | compiler := os.getenv_opt('VINIX_REAL_CC') or { 'gcc' } |
| 19 | mut args := ['--sysroot=${root}', '-specs=${specs}'] |
| 20 | args << os.args[1..] |
| 21 | os.execvp(compiler, args) or { |
| 22 | eprintln('vinix-cc: ${compiler}: ${err}') |
| 23 | exit(1) |
| 24 | } |
| 25 | } |
| 26 | |