chrome: modify chromium source code for SIMD builds

This commit is contained in:
2024-09-07 18:43:00 +08:00
parent a86098f94d
commit 09c12f30de
2 changed files with 2645 additions and 9 deletions

View File

@@ -3,10 +3,13 @@
*/
import { spawn } from 'child_process';
import * as gn from '../commands/gn.js';
import { promisifySpawn } from '../cli.js';
import * as crypto from 'crypto';
import * as fs from "fs";
import path from 'path';
import { lycEnv } from '../environment/index.js';
import { promisifySpawn } from '../cli.js';
import * as gn from '../commands/gn.js';
import { systemdRunOptions } from '../commands/systemd.js';
import { lycEnv, projectRoot } from '../environment/index.js';
export const chromiumSource = '/home/lyc/swchromium-102.0.5005.115';
@@ -77,22 +80,57 @@ const gnExe = path.resolve(chromiumSource, 'buildtools', 'linux64', 'gn-linux-sw
async function configureNoSIMD() {
const hash = '7081b8371ae6460baabc370de4570ebd7e67f923';
const outDir = path.resolve(chromiumSource, 'out', 'Release');
await promisifySpawn(configure(chromiumSource, gnExe, outDir, gnArgs(path.resolve(lycEnv.sharedLLVMInstall, hash))));
}
await configureSIMD();
async function configureSIMD() {
const hash = 'efa1fe54475ed4c333a6ec911cba80b7b4ba0963';
interface ConfigureOptions {
buildDir: string;
const outDir = path.resolve(chromiumSource, 'out', 'simd-noRLE', 'Release');
const configureProcess = configure(chromiumSource, gnExe, outDir, gnArgs(path.resolve(lycEnv.sharedLLVMInstall, hash)));
gnArgs: string[];
}
async function enableSIMDFromSource() {
const assets = path.resolve(projectRoot, 'assets');
const chromiumSIMDGN = path.resolve(assets, 'chromium', 'build-simd.gn');
const chromiumBuildGN = path.resolve(chromiumSource, 'build', 'config', 'compiler', 'BUILD.gn');
await fs.promises.copyFile(chromiumSIMDGN, chromiumBuildGN);
}
await invokeNinja();
async function invokeNinja() {
const hash = 'c9094783eb43868cdbcf26b3266b0231d8fbd6e6';
const uuid = crypto.randomUUID();
const buildDir = path.resolve(chromiumSource, 'out', hash, 'Release');
await enableSIMDFromSource();
const configureProcess = configure(chromiumSource, gnExe, buildDir, gnArgs(`/tmp/llvm-ly-install/${hash}`));
configureProcess.stdout.pipe(process.stdout);
configureProcess.stderr.pipe(process.stderr);
await promisifySpawn(configureProcess);
const systemdUnitName = uuid;
console.log(`Running chromium build (hash: ${hash}) as ${systemdUnitName}`);
await promisifySpawn(spawn('systemd-run',
[
...systemdRunOptions({ user: true, unit: systemdUnitName }),
'ninja',
'-C',
buildDir,
'chrome'
]
))
}