[vdso] use the default arch/abi flags in risc-v vDSO building.

This commit is contained in:
BernardXiong 2025-06-23 23:42:31 +08:00 committed by Rbb666
parent 9a8dec35c1
commit a5359b7223
1 changed files with 27 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import os
import sys
import subprocess
arguments = sys.argv[2]
vdso_usr = arguments
@ -7,7 +8,32 @@ vdso_path = os.path.join(vdso_usr, '..', '..', '..')
EXEC_PATH = os.getenv('RTT_EXEC_PATH') or '/usr/bin'
PREFIX = os.getenv('RTT_CC_PREFIX') or 'riscv64-none-elf-'
DEVICE = os.getenv('RTT_DEVICE') or ' -march=rv64imafdc -mabi=lp64'
def get_riscv64_default_arch_abi(gcc_bin):
try:
result = subprocess.check_output(
[gcc_bin, '-Q', '--help=target'],
universal_newlines=True
)
arch = None
abi = None
for line in result.splitlines():
if '-march=' in line and '[default]' in line:
arch = line.strip().split()[0]
if '-mabi=' in line and '[default]' in line:
abi = line.strip().split()[0]
return arch, abi
except Exception as e:
print("Error getting arch/abi:", e)
return None, None
# get the gcc path
CC_BIN = PREFIX + 'gcc'
arch, abi = get_riscv64_default_arch_abi(CC_BIN)
if arch and abi:
DEVICE = f' {arch} {abi} '
else:
DEVICE = ' -march=rv64imafdc -mabi=lp64' # fallback
CC = PREFIX + 'gcc'
CPP = PREFIX + 'cpp'