build/llvmPackages: add --msimd-math to set -msimd option while compiling libpgmath

This commit is contained in:
2025-01-22 10:07:02 +08:00
parent 2f65e6f741
commit f4c8deda6b
2 changed files with 18 additions and 3 deletions

View File

@@ -21,6 +21,11 @@ const args = await yargs(hideBin(process.argv))
describe: "Install prefix",
type: "string",
})
.option("msimd-math", {
describe: "Add -msimd for libpgmath",
type: "boolean",
demandOption: true,
})
.help()
.parse();
@@ -38,7 +43,8 @@ const packages = llvmPackages({
platform: {
buildPlatform: { arch: arch() },
hostPlatform: { arch: arch() },
}
},
enableLibpgmathSIMD: args['msimd-math']
});
for (const pkg of packages) {

View File

@@ -59,6 +59,8 @@ export interface LLVMPackageOptions {
buildDir: (packageName: 'llvm' | 'libpgmath' | 'cflang') => string,
platform: PackagePlatform;
enableLibpgmathSIMD: boolean;
};
export function llvmPackages({
@@ -68,6 +70,7 @@ export function llvmPackages({
buildDir,
cmakeDefinitionOverrides,
spawnOverrides,
enableLibpgmathSIMD = false,
}: LLVMPackageOptions & LLVMPackageOverrides): PackageTask[] {
const rm = "rm";
const cmake = "cmake";
@@ -135,13 +138,19 @@ export function llvmPackages({
configurePhase: async () => {
await promisifySpawn(spawn(rm, ["-rf", build], spawnOptions));
// Flags shared between C and C++ compiler.
const cxFlags = ["-mlong-double-64"];
if (enableLibpgmathSIMD) {
cxFlags.push("-msimd");
}
// Configure libpgmath.
await promisifySpawn(spawn(cmake, command({
definitions: variable({
...general,
...{
CMAKE_C_FLAGS: "-mlong-double-64",
CMAKE_CXX_FLAGS: "-mlong-double-64",
CMAKE_C_FLAGS: cxFlags.join(" "),
CMAKE_CXX_FLAGS: cxFlags.join(" "),
CMAKE_C_COMPILER: path.join(installPrefix, "bin", "clang"),
CMAKE_CXX_COMPILER: path.join(installPrefix, "bin", "clang++"),
} as GeneralVariable,