From 839ef6fbbb2698ccd494375d6833e7c4458c9b0c Mon Sep 17 00:00:00 2001 From: diviocity Date: Sun, 29 Nov 2026 23:26:49 +0100 Subject: [PATCH] vinix-cc: select the C++ compiler through vinix-c++ --- README.md | 1 + tools/vinix-cc.v | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 227dbc5..2af204c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ cp -R musl busybox "$work/" export MAKEFLAGS=-j1 v -o "$work/feed" tests/feed.v v -o "$work/vinix-cc" tools/vinix-cc.v +ln -s vinix-cc "$work/vinix-c++" export PATH="$work:$PATH" vpac --native-build "$work/musl/PKGBUILD.vile" "$work/musl.txt" "$work/feed" keys "$work/test-keys" diff --git a/tools/vinix-cc.v b/tools/vinix-cc.v index f3b3454..3d61386 100644 --- a/tools/vinix-cc.v +++ b/tools/vinix-cc.v @@ -5,21 +5,27 @@ module main import os fn main() { + driver := os.base(os.args[0]) root := os.getenv('VPAC_MAKEPKG_ROOT') if !os.is_abs_path(root) { - eprintln('vinix-cc requires an absolute VPAC_MAKEPKG_ROOT') + eprintln('${driver} requires an absolute VPAC_MAKEPKG_ROOT') exit(1) } specs := os.join_path(root, 'usr/lib/musl-gcc-sysroot.specs') if !os.is_file(specs) { - eprintln('vinix-cc: missing installed musl specs at ${specs}') + eprintln('${driver}: missing installed musl specs at ${specs}') exit(1) } - compiler := os.getenv_opt('VINIX_REAL_CC') or { os.getenv('CROSS_COMPILE') + 'gcc' } + prefix := os.getenv('CROSS_COMPILE') + compiler := if driver == 'vinix-c++' { + os.getenv_opt('VINIX_REAL_CXX') or { prefix + 'g++' } + } else { + os.getenv_opt('VINIX_REAL_CC') or { prefix + 'gcc' } + } mut args := ['--sysroot=${root}', '-specs=${specs}'] args << os.args[1..] os.execvp(compiler, args) or { - eprintln('vinix-cc: ${compiler}: ${err}') + eprintln('${driver}: ${compiler}: ${err}') exit(1) } } -- 2.56.1