From f4c8deda6b3be334920076ff11f84335f96cced5 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Wed, 22 Jan 2025 10:07:02 +0800 Subject: [PATCH] build/llvmPackages: add --msimd-math to set -msimd option while compiling libpgmath --- src/bin/build-llvm.ts | 8 +++++++- src/build/llvmPackages.ts | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/bin/build-llvm.ts b/src/bin/build-llvm.ts index 766520e..11737b9 100644 --- a/src/bin/build-llvm.ts +++ b/src/bin/build-llvm.ts @@ -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) { diff --git a/src/build/llvmPackages.ts b/src/build/llvmPackages.ts index 8c6b0e0..8ab4b94 100644 --- a/src/build/llvmPackages.ts +++ b/src/build/llvmPackages.ts @@ -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,