File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
components/lwp/vdso/user/arch/risc-v Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import sys
3
+ import subprocess
3
4
4
5
arguments = sys .argv [2 ]
5
6
vdso_usr = arguments
6
7
vdso_path = os .path .join (vdso_usr , '..' , '..' , '..' )
7
8
8
9
EXEC_PATH = os .getenv ('RTT_EXEC_PATH' ) or '/usr/bin'
9
10
PREFIX = os .getenv ('RTT_CC_PREFIX' ) or 'riscv64-none-elf-'
10
- DEVICE = os .getenv ('RTT_DEVICE' ) or ' -march=rv64imafdc -mabi=lp64'
11
+
12
+ def get_riscv64_default_arch_abi (gcc_bin ):
13
+ try :
14
+ result = subprocess .check_output (
15
+ [gcc_bin , '-Q' , '--help=target' ],
16
+ universal_newlines = True
17
+ )
18
+ arch = None
19
+ abi = None
20
+ for line in result .splitlines ():
21
+ if '-march=' in line and '[default]' in line :
22
+ arch = line .strip ().split ()[0 ]
23
+ if '-mabi=' in line and '[default]' in line :
24
+ abi = line .strip ().split ()[0 ]
25
+ return arch , abi
26
+ except Exception as e :
27
+ print ("Error getting arch/abi:" , e )
28
+ return None , None
29
+
30
+ # get the gcc path
31
+ CC_BIN = PREFIX + 'gcc'
32
+ arch , abi = get_riscv64_default_arch_abi (CC_BIN )
33
+ if arch and abi :
34
+ DEVICE = f' { arch } { abi } '
35
+ else :
36
+ DEVICE = ' -march=rv64imafdc -mabi=lp64' # fallback
11
37
12
38
CC = PREFIX + 'gcc'
13
39
CPP = PREFIX + 'cpp'
You can’t perform that action at this time.
0 commit comments