Skip to content

Commit 5fae1fb

Browse files
committed
scripts: waifulib: compiler_optimizations: automatically enable xtheadvector extension on C910 (like T-Head TH1520)
1 parent 895b28d commit 5fae1fb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/waifulib/compiler_optimizations.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
try: from fwgslib import get_flags_by_type, get_flags_by_compiler
1515
except: from waflib.extras.fwgslib import get_flags_by_type, get_flags_by_compiler
1616
from waflib.Configure import conf
17-
from waflib import Logs
17+
from waflib import Logs, Utils
1818

1919
'''
2020
Flags can be overriden and new types can be added
@@ -257,6 +257,20 @@ def get_optimization_flags(conf):
257257
# this port don't have stack printing support
258258
cflags.remove('-fasynchronous-unwind-tables')
259259

260+
if conf.env.DEST_CPU == 'riscv' and conf.env.DEST_OS == 'linux' and conf.options.BUILD_TYPE in ['release', 'fast']:
261+
# try to guess better flags, as march=native is not supported in my toolchain yet
262+
# shoddy work, remove later
263+
s = None
264+
for line in Utils.readf('/proc/cpuinfo').splitlines():
265+
if line.startswith('uarch'):
266+
s = line[line.find(':') + 2:]
267+
break
268+
march = None
269+
if s == 'thead,c910':
270+
march = '-march=rv64gc_xtheadvector'
271+
272+
conf.msg('Guessed best -march', march)
273+
260274
if conf.env.COMPILER_CC in ['gcc', 'clang'] and conf.options.LIMITED_DEBUGINFO:
261275
# probably not a good idea to do this, but it should save space on Android builds especially
262276
# that are never going to be run under debugger, but we still want that readable fileline

0 commit comments

Comments
 (0)