libc++
Some checks failed
demo.yaml / libc++ (push) Failing after 0s

This commit is contained in:
Jorijn van der Graaf 2026-03-02 15:24:45 +01:00
commit 9bd12660eb
8 changed files with 94 additions and 60 deletions

View file

@ -211,12 +211,8 @@ namespace Crafter {
fs::create_directories(exeDir/config.target);
const std::string stdPcm = std::format("{}/{}/std.pcm", exeDir.string(), config.target);
std::string gccVersion = RunCommand("g++ -dumpversion");
gccVersion.pop_back();
fs::path stdCc = fs::path(std::format("/usr/include/c++/{}/bits/std.cc", gccVersion));
if(!fs::exists(stdPcm) || fs::last_write_time(stdPcm) < fs::last_write_time(stdCc)) {
std::string result = RunCommand(std::format("cp {} {}/{}/std.cppm\nclang++ --target={} -std=c++26 -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile {}/{}/std.cppm -o {}", stdCc.string(), exeDir.string(), config.target, config.target, exeDir.string(), config.target, stdPcm));
if(!fs::exists(stdPcm) || fs::last_write_time(stdPcm) < fs::last_write_time("/usr/share/libc++/v1/std.cppm")) {
std::string result = RunCommand(std::format("clang++ --target={} -std=c++26 -stdlib=libc++ -march=native -mtune=native -O3 -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile /usr/share/libc++/v1/std.cppm -o {}", config.target, stdPcm));
if(result != "") {
throw std::runtime_error(result);
}

View file

@ -268,7 +268,6 @@ namespace Crafter {
if(config.contains("dependencies")) {
for (auto it : config["dependencies"]) {
fs::path path = it["path"].get<std::string>();
std::string configName = it["configuration"].get<std::string>();
if(path.string().ends_with(".git")) {
fs::path name = path.filename();
name.replace_extension();
@ -305,7 +304,20 @@ namespace Crafter {
// Update path to the project.json of the dependency
path = cacheDir / depFolder / "project.json";
}
if(it.contains("type")) {
std::string type = it["type"].get<std::string>();
if(type == "cmake") {
std::string options;
if(it.contains("options")) {
options = it["options"].get<std::string>();
}
cmakeDeps.emplace_back(path.parent_path(), options);
continue;
}
}
std::string configName = it["configuration"].get<std::string>();
// Create a Project object for the dependency
std::unique_ptr<Project> depProject = std::make_unique<Project>(std::move(path), configName);

View file

@ -74,7 +74,7 @@ namespace Crafter {
result += RunClang(std::format("cd {} && {} {}.cppm --precompile -o {}.pcm", pcmDir.string(), clang, path.string(), path.filename().string()));
#endif
result += RunClang(std::format("{} {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
result += RunClang(std::format("{} -Wno-unused-command-line-argument {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
if(result.empty()) {
compiled.store(CRAFTER_COMPILE_STATUS_COMPLETED);
compiled.notify_all();
@ -157,7 +157,7 @@ namespace Crafter {
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
result += RunClang(std::format("cd {} && {} {}.cppm --precompile -o {}.pcm", pcmDir.string(), clang, path.string(), path.filename().string()));
#endif
result += RunClang(std::format("{} {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
result += RunClang(std::format("{} -Wno-unused-command-line-argument {}.pcm -c -o {}.o", clang, (pcmDir/path.filename()).string(), (buildDir/path.filename()).string()));
if(result.empty()) {
compiled.store(CRAFTER_COMPILE_STATUS_COMPLETED);
compiled.notify_all();

View file

@ -246,7 +246,7 @@ namespace Crafter {
std::replace(editedTarget.begin(), editedTarget.end(), '-', '_');
#ifdef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_linux_gnu
std::string command = std::format("clang++ --target={} -march={} -mtune={} -std={} -D CRAFTER_BUILD_CONFIGURATION_TARGET_{} -fprebuilt-module-path={}", config.target, config.march, config.march, config.standard, editedTarget, (exeDir/config.target).string());
std::string command = std::format("clang++ -stdlib=libc++ --target={} -march={} -mtune={} -std={} -D CRAFTER_BUILD_CONFIGURATION_TARGET_{} -fprebuilt-module-path={} -I{} -I{}", config.target, config.march, config.march, config.standard, editedTarget, (exeDir/config.target).string(), buildDir.string(), (exeDir/"cloneCache").string());
#endif
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)
std::string command = std::format("clang-cl.exe /EHsc --target={} -march={} -mtune={} /std:{} /D CRAFTER_BUILD_CONFIGURATION_TARGET_{} -fprebuilt-module-path={} -Wno-unused-command-line-argument", config.target, config.march, config.march, config.standard, editedTarget, (exeDir/config.target).string());
@ -303,7 +303,10 @@ namespace Crafter {
command += std::format(" -fprebuilt-module-path={}", pcmDir.string());
std::string cmakeBuildType;
if(config.debug) {
cmakeBuildType = "Debug";
#ifdef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_linux_gnu
command += " -g -D CRAFTER_BUILD_CONFIGURATION_DEBUG";
#endif
@ -311,6 +314,7 @@ namespace Crafter {
command += " -g /MDd /D CRAFTER_BUILD_CONFIGURATION_DEBUG";
#endif
} else {
cmakeBuildType = "Release";
#ifdef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_linux_gnu
command += " -O3";
#endif
@ -353,6 +357,12 @@ namespace Crafter {
});
}
for(const CmakeDep& cmake : config.cmakeDeps) {
depThreads.emplace_back([&cmake, &cmakeBuildType, &buildDir](){
system(std::format("cd {} && cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=\"-stdlib=libc++\" -DCMAKE_EXE_LINKER_FLAGS=\"-stdlib=libc++\" -DCMAKE_SHARED_LINKER_FLAGS=\"-stdlib=libc++\" -DCMAKE_BUILD_TYPE={} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY={} -DCMAKE_LIBRARY_OUTPUT_DIRECTORY={} {} && cmake --build build --config {}", cmake.path.string(), cmakeBuildType, buildDir.string(), buildDir.string(), cmake.options, cmakeBuildType).c_str());
});
}
for(std::thread& thread : depThreads) {
thread.join();
}
@ -428,6 +438,8 @@ namespace Crafter {
command += " -L/usr/local/lib";
}
command += std::format(" -L{}", buildDir.string());
if(config.type != CRAFTER_CONFIGURATION_TYPE_LIBRARY) {
#ifdef CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_linux_gnu
command += libsString;
@ -460,7 +472,7 @@ namespace Crafter {
if(config.target == "wasm32-wasi") {
outputName += ".wasm";
}
buildResult.errors = RunClang(std::format("{}{} -o {} -fuse-ld=lld", command, files, (binDir/outputName).string()));
buildResult.errors = RunClang(std::format("{}{} -o {} -fuse-ld=lld ", command, files, (binDir/outputName).string()));
#endif
#if defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_pc_windows_msvc) || defined(CRAFTER_BUILD_CONFIGURATION_TARGET_x86_64_w64_mingw32)