build-llvm: init, for llvm packages
This commit is contained in:
13
assets/omp.diff
Normal file
13
assets/omp.diff
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
|
||||
index bdb867e352f7..a0b6e50e0ce8 100644
|
||||
--- a/openmp/runtime/src/CMakeLists.txt
|
||||
+++ b/openmp/runtime/src/CMakeLists.txt
|
||||
@@ -148,7 +148,7 @@ libomp_get_libflags(LIBOMP_CONFIGURED_LIBFLAGS)
|
||||
if(OPENMP_STANDALONE_BUILD OR (NOT OPENMP_ENABLE_LIBOMP_PROFILING))
|
||||
add_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES})
|
||||
# Linking command will include libraries in LIBOMP_CONFIGURED_LIBFLAGS
|
||||
- target_link_libraries(omp ${LIBOMP_CONFIGURED_LIBFLAGS} ${CMAKE_DL_LIBS})
|
||||
+ target_link_libraries(omp ${LIBOMP_CONFIGURED_LIBFLAGS} ${CMAKE_DL_LIBS} "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports_so.txt")
|
||||
else()
|
||||
add_llvm_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES} PARTIAL_SOURCES_INTENDED
|
||||
LINK_LIBS ${LIBOMP_CONFIGURED_LIBFLAGS} ${CMAKE_DL_LIBS}
|
||||
164
build-llvm.ts
Normal file
164
build-llvm.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
import path from "path";
|
||||
import { GeneralVariable, LLVMVariable, command, variable } from "./commands/cmake";
|
||||
import { LLVM_SRC, SYSROOT_PREFIX } from "./environment";
|
||||
import { PackageTask, buildPackage } from "./build";
|
||||
import { checkedSpawnSync } from "./cli";
|
||||
|
||||
|
||||
function llvmPackages(src: string, installPrefix: string): PackageTask[] {
|
||||
const LLVM_BUILD = path.join(src, "build-dev");
|
||||
const rm = "rm";
|
||||
const cmake = "cmake";
|
||||
|
||||
const llvmVar: LLVMVariable = {
|
||||
LLVM_ENABLE_PROJECTS: ["clang", "clang-tools-extra", "lld", "openmp"],
|
||||
LLVM_TARGETS_TO_BUILD: ["Sw64"],
|
||||
LIBOMP_ARCH: "Sw64",
|
||||
LIBOMP_USE_ITT_NOTIFY: false,
|
||||
};
|
||||
|
||||
const general: GeneralVariable = {
|
||||
CMAKE_BUILD_TYPE: "Release",
|
||||
CMAKE_INSTALL_PREFIX: installPrefix,
|
||||
CMAKE_SYSROOT: SYSROOT_PREFIX,
|
||||
};
|
||||
|
||||
const mkBuildPhase = (build: string) => {
|
||||
checkedSpawnSync(cmake, ["--build", build], { stdio: 'inherit' });
|
||||
};
|
||||
|
||||
const mkInstallPhase = (build: string) => {
|
||||
checkedSpawnSync(cmake, ["--build", build, "--target", "install"], { stdio: 'inherit' });
|
||||
};
|
||||
|
||||
function mkLLVMPackage(): PackageTask {
|
||||
const build = path.join(LLVM_BUILD, "llvm");
|
||||
return {
|
||||
name: "llvm",
|
||||
patchPhase: () => {
|
||||
// Apply llvm omp patch
|
||||
checkedSpawnSync("git",
|
||||
[
|
||||
"apply",
|
||||
path.join(process.cwd(), "assets", "omp.diff"),
|
||||
], { stdio: "inherit", cwd: src });
|
||||
|
||||
process.env.LD_LIBRARY_PATH = [
|
||||
path.join(SYSROOT_PREFIX, 'usr', 'lib'),
|
||||
path.join(SYSROOT_PREFIX, 'lib'),
|
||||
].join(':');
|
||||
},
|
||||
configurePhase: () => {
|
||||
// Configure
|
||||
checkedSpawnSync(cmake, command({
|
||||
definitions: variable({
|
||||
...llvmVar,
|
||||
...general,
|
||||
}),
|
||||
generator: "Ninja",
|
||||
// LLVM cmake root is under /llvm directory
|
||||
pathToSource: path.join(src, "llvm"),
|
||||
pathToBuild: build,
|
||||
}), { stdio: "inherit" });
|
||||
},
|
||||
buildPhase: () => mkBuildPhase(build),
|
||||
installPhase: () => mkInstallPhase(build),
|
||||
};
|
||||
}
|
||||
|
||||
function mkLibpgmathPackage(): PackageTask {
|
||||
const build = path.join(LLVM_BUILD, "libpgmath");
|
||||
return {
|
||||
name: "libpgmath",
|
||||
configurePhase: () => {
|
||||
checkedSpawnSync(rm, ["-rf", build], { stdio: "inherit" });
|
||||
|
||||
// Configure libpgmath.
|
||||
checkedSpawnSync(cmake, command({
|
||||
definitions: variable({
|
||||
...general,
|
||||
...{
|
||||
CMAKE_C_FLAGS: "-msimd",
|
||||
CMAKE_CXX_FLAGS: "-msimd",
|
||||
CMAKE_C_COMPILER: path.join(installPrefix, "bin", "clang"),
|
||||
CMAKE_CXX_COMPILER: path.join(installPrefix, "bin", "clang++"),
|
||||
} as GeneralVariable,
|
||||
}),
|
||||
generator: "Ninja",
|
||||
pathToSource: path.join(src, "cflang", "runtime", "libpgmath"),
|
||||
pathToBuild: build,
|
||||
}), { stdio: "inherit" });
|
||||
},
|
||||
buildPhase: () => mkBuildPhase(build),
|
||||
installPhase: () => mkInstallPhase(build),
|
||||
};
|
||||
}
|
||||
|
||||
function mkCflangPackage(): PackageTask {
|
||||
const build = path.join(LLVM_BUILD, "cflang");
|
||||
return {
|
||||
name: "cflang",
|
||||
configurePhase: () => {
|
||||
checkedSpawnSync(rm, ["-rf", build], { stdio: "inherit" });
|
||||
|
||||
// Configure cflang.
|
||||
checkedSpawnSync(cmake, command({
|
||||
definitions: variable({
|
||||
...llvmVar,
|
||||
...general,
|
||||
...{
|
||||
CMAKE_C_COMPILER: path.join(installPrefix, "bin", "clang"),
|
||||
CMAKE_CXX_COMPILER: path.join(installPrefix, "bin", "clang++"),
|
||||
CMAKE_Fortran_COMPILER: path.join(installPrefix, "bin", "flang"),
|
||||
CMAKE_Fortran_COMPILER_ID: "Flang",
|
||||
} as GeneralVariable,
|
||||
// Flang specific variables.
|
||||
FLANG_INCLUDE_DOCS: true,
|
||||
FLANG_LLVM_EXTENSIONS: true,
|
||||
WITH_WERROR: false,
|
||||
LLVM_CONFIG: path.join(installPrefix, "bin", "llvm-config"),
|
||||
}),
|
||||
generator: "Unix Makefiles",
|
||||
pathToSource: path.join(src, "cflang"),
|
||||
pathToBuild: build,
|
||||
}), { stdio: "inherit" });
|
||||
},
|
||||
buildPhase: () => mkBuildPhase(build),
|
||||
installPhase: () => mkInstallPhase(build),
|
||||
};
|
||||
}
|
||||
|
||||
return [mkLLVMPackage(), mkLibpgmathPackage(), mkCflangPackage()];
|
||||
}
|
||||
|
||||
|
||||
function buildLLVMHash(src: string, rev: string) {
|
||||
// Checkout a git rev in some git repo.
|
||||
checkedSpawnSync("git", ["checkout", rev], { stdio: "inherit", cwd: src });
|
||||
checkedSpawnSync("git", ["reset", "--hard", "HEAD"], { stdio: "inherit", cwd: src });
|
||||
|
||||
const llvmInstall = path.join(src, "local", "installed");
|
||||
|
||||
llvmPackages(src, path.join(llvmInstall, rev))
|
||||
.forEach(buildPackage);
|
||||
}
|
||||
|
||||
[
|
||||
// "85e4fed0c9e4cd4ab8bce89f307127ccbad31294",
|
||||
"09eed7875e9a5fa8597a3ba88bd5c5bcc18fff9b",
|
||||
"1231573a5c29fc1ea5783b0f8cdd7442d48111b5",
|
||||
"0fef7853ab023a4752c84f889f98461bd7f37728",
|
||||
"cc2144e0cb4e09ca4c4e77ddb124148d3a50ed30",
|
||||
"49025c97a834df250cec6b6c9d292951284308d6",
|
||||
"5a48db93c5ae983513da54929f0600441c2584e7",
|
||||
"76318811282fdfc65435628026636a748b015cb8",
|
||||
"20713c101717338706b502d25a9c57e73b4d1dc9",
|
||||
"33661f021f637512c3a986f1cf8f5828dd974114",
|
||||
"793edc371ded601900fac19144cbddfd9a881b00",
|
||||
"a44d0af59e3a8bac5e2f6c0d02b95ae1853928f2",
|
||||
"9dbcdda68d41590485da61fe9fc09e92da9cadad",
|
||||
"77bfe439d08adccf7a07b3393d8dc0281b7e4792",
|
||||
"a5449bdd6d7df432a5cced42cd137d54eb027e03",
|
||||
"adf1aaa1e498957a367c3052bb1195cef92a01c0",
|
||||
"4a844972f38e2b44519b894ccfe54b6c92051cb7",
|
||||
].forEach(hash => buildLLVMHash(LLVM_SRC, hash));
|
||||
Reference in New Issue
Block a user