chromium: init, misc build sripts
This commit is contained in:
2603
assets/chromium/gn/no-rca.gn
Normal file
2603
assets/chromium/gn/no-rca.gn
Normal file
File diff suppressed because it is too large
Load Diff
2594
assets/chromium/gn/scalar.gn
Normal file
2594
assets/chromium/gn/scalar.gn
Normal file
File diff suppressed because it is too large
Load Diff
@@ -64,27 +64,39 @@ function gnArgsToList(o: GNArgs) {
|
|||||||
'dcheck_always_on=false',
|
'dcheck_always_on=false',
|
||||||
'enable_libaom=false',
|
'enable_libaom=false',
|
||||||
`clang_base_path="${o.clangBasePath}"`,
|
`clang_base_path="${o.clangBasePath}"`,
|
||||||
...undefList(o.symbolLevel, x => `symbol_level=${x}`),
|
...undefList(o.symbolLevel, x => [ `symbol_level=${x}` ]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ConfigureOptions {
|
||||||
|
source: string;
|
||||||
|
gnExe: string;
|
||||||
|
outDir: string;
|
||||||
|
gnArgs: GNArgs;
|
||||||
|
buildProfile: "simd" | "norca";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke meta-build system "gn", returns the process.
|
* Invoke meta-build system "gn", returns the process.
|
||||||
*/
|
*/
|
||||||
export function configure(source: string, gnExe: string, outDir: string, gnArgs: GNArgs) {
|
export async function configure({ source, gnExe, outDir, gnArgs, buildProfile }: ConfigureOptions) {
|
||||||
|
const assets = path.resolve(projectRoot, 'assets');
|
||||||
|
const chromiumBuildGN = path.resolve(chromiumSource, 'build', 'config', 'compiler', 'BUILD.gn');
|
||||||
|
|
||||||
|
const replacerGN = (() => {
|
||||||
|
const gnDir = path.resolve(assets, "chromium", "gn");
|
||||||
|
if (buildProfile == "norca") {
|
||||||
|
return path.resolve(gnDir, "no-rca.gn");
|
||||||
|
} else if (buildProfile == "simd") {
|
||||||
|
return path.resolve(gnDir, "simd.gn");
|
||||||
|
}
|
||||||
|
return path.resolve(gnDir, "scalar.gn");
|
||||||
|
})();
|
||||||
|
await fs.promises.copyFile(replacerGN, chromiumBuildGN);
|
||||||
|
|
||||||
return spawn(gnExe, [
|
return spawn(gnExe, [
|
||||||
'gen',
|
'gen',
|
||||||
outDir,
|
outDir,
|
||||||
...gn.generalOptions({ args: gnArgsToList(gnArgs) }),
|
...gn.generalOptions({ args: gnArgsToList(gnArgs) }),
|
||||||
], { cwd: source });
|
], { cwd: source });
|
||||||
}
|
}
|
||||||
|
|
||||||
export 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);
|
|
||||||
}
|
|
||||||
55
src/chromium/configure/closeRCA.ts
Normal file
55
src/chromium/configure/closeRCA.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* -close-rca-pass=true with 3fff408f20f8497b6ff511f7f37b0da96b19a16c compiler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
|
import { chromiumGN } from '../../bin/lib.js';
|
||||||
|
import { chromiumSource } from '../../chromium.js';
|
||||||
|
import * as chromiumConfigure from "../configure.js";
|
||||||
|
import { mkdir } from 'fs/promises';
|
||||||
|
import { promisifySpawn } from '../../cli.js';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import { systemdRunOptions } from '../../commands/systemd.js';
|
||||||
|
import { randomUUID } from 'crypto';
|
||||||
|
|
||||||
|
|
||||||
|
const hash = '3fff408f20f8497b6ff511f7f37b0da96b19a16c';
|
||||||
|
|
||||||
|
const llvmPrefix = `/tmp/llvm-ly-install/${hash}`;
|
||||||
|
|
||||||
|
const outDir = path.resolve(chromiumSource, "out", "simd", "close-rca", hash);
|
||||||
|
|
||||||
|
await mkdir(outDir, { recursive: true });
|
||||||
|
|
||||||
|
const configureProcess = await chromiumConfigure.configure({
|
||||||
|
source: chromiumSource,
|
||||||
|
gnExe: chromiumGN,
|
||||||
|
outDir,
|
||||||
|
gnArgs: {
|
||||||
|
clangBasePath: llvmPrefix,
|
||||||
|
},
|
||||||
|
buildProfile: "norca"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
configureProcess.stdout.pipe(process.stdout);
|
||||||
|
configureProcess.stderr.pipe(process.stderr);
|
||||||
|
|
||||||
|
await promisifySpawn(configureProcess);
|
||||||
|
|
||||||
|
const uuid = randomUUID();
|
||||||
|
|
||||||
|
// Invoke ninja build
|
||||||
|
const systemdUnitName = uuid;
|
||||||
|
|
||||||
|
console.log(`Running chromium build (hash: ${hash}) as ${systemdUnitName}`);
|
||||||
|
|
||||||
|
await promisifySpawn(spawn('systemd-run',
|
||||||
|
[
|
||||||
|
...systemdRunOptions({ user: true, unit: systemdUnitName }),
|
||||||
|
'ninja',
|
||||||
|
'-C',
|
||||||
|
outDir,
|
||||||
|
'chrome'
|
||||||
|
]
|
||||||
|
));
|
||||||
56
src/chromium/configure/symbol.ts
Normal file
56
src/chromium/configure/symbol.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* -close-rca-pass=true with 3fff408f20f8497b6ff511f7f37b0da96b19a16c compiler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
|
import { chromiumGN } from '../../bin/lib.js';
|
||||||
|
import { chromiumSource } from '../../chromium.js';
|
||||||
|
import * as chromiumConfigure from "../configure.js";
|
||||||
|
import { mkdir } from 'fs/promises';
|
||||||
|
import { promisifySpawn } from '../../cli.js';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import { systemdRunOptions } from '../../commands/systemd.js';
|
||||||
|
import { randomUUID } from 'crypto';
|
||||||
|
|
||||||
|
|
||||||
|
const hash = '3fff408f20f8497b6ff511f7f37b0da96b19a16c';
|
||||||
|
|
||||||
|
const llvmPrefix = `/tmp/llvm-ly-install/${hash}`;
|
||||||
|
|
||||||
|
const outDir = path.resolve(chromiumSource, "out", "simd", "symbolic", hash);
|
||||||
|
|
||||||
|
await mkdir(outDir, { recursive: true });
|
||||||
|
|
||||||
|
const configureProcess = await chromiumConfigure.configure({
|
||||||
|
source: chromiumSource,
|
||||||
|
gnExe: chromiumGN,
|
||||||
|
outDir,
|
||||||
|
gnArgs: {
|
||||||
|
clangBasePath: llvmPrefix,
|
||||||
|
symbolLevel: 2,
|
||||||
|
},
|
||||||
|
buildProfile: "norca"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
configureProcess.stdout.pipe(process.stdout);
|
||||||
|
configureProcess.stderr.pipe(process.stderr);
|
||||||
|
|
||||||
|
await promisifySpawn(configureProcess);
|
||||||
|
|
||||||
|
const uuid = randomUUID();
|
||||||
|
|
||||||
|
// Invoke ninja build
|
||||||
|
const systemdUnitName = uuid;
|
||||||
|
|
||||||
|
console.log(`Running chromium build (hash: ${hash}) as ${systemdUnitName}`);
|
||||||
|
|
||||||
|
await promisifySpawn(spawn('systemd-run',
|
||||||
|
[
|
||||||
|
...systemdRunOptions({ user: true, unit: systemdUnitName }),
|
||||||
|
'ninja',
|
||||||
|
'-C',
|
||||||
|
outDir,
|
||||||
|
'chrome'
|
||||||
|
]
|
||||||
|
));
|
||||||
82
src/chromium/link.ts
Normal file
82
src/chromium/link.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import { spawn } from 'child_process';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link "chrome" executable
|
||||||
|
*/
|
||||||
|
export function linkChrome(linker: string, cwd: string) {
|
||||||
|
return spawn("python3", [
|
||||||
|
"../../../build/toolchain/gcc_link_wrapper.py",
|
||||||
|
"--output=./chrome",
|
||||||
|
"--",
|
||||||
|
linker,
|
||||||
|
"-Wl,--version-script=../../../build/linux/chrome.map",
|
||||||
|
"-Wl,--fatal-warnings",
|
||||||
|
"-Wl,--build-id",
|
||||||
|
"-fPIC",
|
||||||
|
"-Wl,-z,noexecstack",
|
||||||
|
"-Wl,-z,relro",
|
||||||
|
"-Wl,-z,now",
|
||||||
|
"-no-canonical-prefixes",
|
||||||
|
"-Wl,-O2",
|
||||||
|
"-Wl,--gc-sections",
|
||||||
|
"-rdynamic",
|
||||||
|
"-Wl,-z,defs",
|
||||||
|
"-Wl,--as-needed",
|
||||||
|
"-nostdlib++",
|
||||||
|
"-pie",
|
||||||
|
"-Wl,--disable-new-dtags",
|
||||||
|
"-o",
|
||||||
|
"./chrome",
|
||||||
|
"-Wl,--start-group",
|
||||||
|
"@./chrome.rsp",
|
||||||
|
"-Wl,--end-group",
|
||||||
|
"-ldl",
|
||||||
|
"-lpthread",
|
||||||
|
"-lrt",
|
||||||
|
"-lgmodule-2.0",
|
||||||
|
"-lgobject-2.0",
|
||||||
|
"-lgthread-2.0",
|
||||||
|
"-lglib-2.0",
|
||||||
|
"-lnss3",
|
||||||
|
"-lnssutil3",
|
||||||
|
"-lsmime3",
|
||||||
|
"-lplds4",
|
||||||
|
"-lplc4",
|
||||||
|
"-lnspr4",
|
||||||
|
"-latk-1.0",
|
||||||
|
"-latk-bridge-2.0",
|
||||||
|
"-lcups",
|
||||||
|
"-lgio-2.0",
|
||||||
|
"-ldbus-1",
|
||||||
|
"-latomic",
|
||||||
|
"-lresolv",
|
||||||
|
"-ljpeg",
|
||||||
|
"-lexpat",
|
||||||
|
"-luuid",
|
||||||
|
"-ldrm",
|
||||||
|
"-lm",
|
||||||
|
"-lX11",
|
||||||
|
"-lXcomposite",
|
||||||
|
"-lXdamage",
|
||||||
|
"-lXext",
|
||||||
|
"-lXfixes",
|
||||||
|
"-lXrender",
|
||||||
|
"-lXrandr",
|
||||||
|
"-lXtst",
|
||||||
|
"-lxcb",
|
||||||
|
"-lxkbcommon",
|
||||||
|
"-lgbm",
|
||||||
|
"-lwayland-client",
|
||||||
|
"-lpangocairo-1.0",
|
||||||
|
"-lpango-1.0",
|
||||||
|
"-lcairo",
|
||||||
|
"-lasound",
|
||||||
|
"-lpulse",
|
||||||
|
"-lXi",
|
||||||
|
"-lpci",
|
||||||
|
"-lz",
|
||||||
|
"-latspi",
|
||||||
|
"-lxshmfence",
|
||||||
|
"-llcms2",
|
||||||
|
], { cwd });
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { chromiumSource } from '../../chromium.js';
|
import { chromiumSource } from '../../chromium.js';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import { linkChrome } from '../link.js';
|
||||||
|
import { promisifySpawn } from '../../cli.js';
|
||||||
|
|
||||||
const objects = [
|
const objects = [
|
||||||
"obj/skia/skia_core_and_effects/SkBlitRow_D32.o",
|
"obj/skia/skia_core_and_effects/SkBlitRow_D32.o",
|
||||||
@@ -17,7 +19,13 @@ const objects = [
|
|||||||
const scalarBuild = path.resolve(chromiumSource, "out", "Release");
|
const scalarBuild = path.resolve(chromiumSource, "out", "Release");
|
||||||
const simdBuild = path.resolve(chromiumSource, "out", "c9094783eb43868cdbcf26b3266b0231d8fbd6e6", "Release");
|
const simdBuild = path.resolve(chromiumSource, "out", "c9094783eb43868cdbcf26b3266b0231d8fbd6e6", "Release");
|
||||||
|
|
||||||
await Promise.all(objects.map(async x => {
|
// await Promise.all(objects.map(async x => {
|
||||||
// Copy object from scalar directory to simd directory
|
// // Copy object from scalar directory to simd directory
|
||||||
await fs.promises.copyFile(path.resolve(scalarBuild, x), path.resolve(simdBuild, x));
|
// await fs.promises.copyFile(path.resolve(scalarBuild, x), path.resolve(simdBuild, x));
|
||||||
}))
|
// }));
|
||||||
|
|
||||||
|
// Invoke chromium linking command.
|
||||||
|
const linker = linkChrome('/tmp/llvm-ly-install/c9094783eb43868cdbcf26b3266b0231d8fbd6e6/bin/clang++', simdBuild);
|
||||||
|
linker.stdout.pipe(process.stdout);
|
||||||
|
linker.stderr.pipe(process.stderr);
|
||||||
|
await promisifySpawn(linker);
|
||||||
@@ -9,6 +9,6 @@ export interface GeneralOptions {
|
|||||||
|
|
||||||
export function generalOptions(o: GeneralOptions) {
|
export function generalOptions(o: GeneralOptions) {
|
||||||
return [
|
return [
|
||||||
...optFlagEq("--args", o.args?.join(' ')),
|
...optFlagEq("--args", o.args?.join("\n")),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user