bin/runcpu: support optimize flag configuration

This commit is contained in:
2025-04-25 12:07:50 +08:00
parent e9b8d04a11
commit 49284ba162

View File

@@ -29,6 +29,15 @@ const argv = await yargs(hideBin(process.argv))
choices: ['test', 'train', 'ref'],
default: 'ref',
})
.option('optimize-profile', {
type: 'string',
choices: ['O2', 'base'],
demandOption: true,
})
.option('allow-misaligned', {
type: 'boolean',
default: false,
})
.option('spec', {
alias: 's',
type: 'string',
@@ -90,7 +99,7 @@ const uuid = crypto.randomUUID();
const prefix = path.resolve(argv.compilerPrefix);
const o3LTOFlags = [
const baseFlags = [
"-O3",
"-flto",
"-fuse-ld=lld",
@@ -109,7 +118,8 @@ const specProc = await spawnSPECWithID(
spec,
{
optimize: [
"-O2",
...argv.optimizeProfile === "O2" ? ["-O2"] : baseFlags,
...argv.allowMisaligned ? unalignedFlags : [],
...sw64TargetOptions({ simd: argv.simd }),
...argv.compilerSuite == "llvm" ? [sunway.mcpu(sunwayGeneration)] : [], // Only add -mcpu for llvm
],