forked from lix-project/lix
Merge changes Ic0dfcfe2,Ibe73851f,Ia7a8df1c,I400b2031 into main
* changes: package.nix: remove dead code diff-closures: remove gratuitous copy tree-wide: NULL -> nullptr libutil: rip out GNU Hurd support code
This commit is contained in:
commit
c4c7cb7613
14
package.nix
14
package.nix
|
@ -92,19 +92,7 @@ let
|
||||||
|
|
||||||
# Reimplementation of Nixpkgs' Meson cross file, with some additions to make
|
# Reimplementation of Nixpkgs' Meson cross file, with some additions to make
|
||||||
# it actually work.
|
# it actually work.
|
||||||
mesonCrossFile =
|
mesonCrossFile = builtins.toFile "lix-cross-file.conf" ''
|
||||||
let
|
|
||||||
cpuFamily =
|
|
||||||
platform:
|
|
||||||
with platform;
|
|
||||||
if isAarch32 then
|
|
||||||
"arm"
|
|
||||||
else if isx86_32 then
|
|
||||||
"x86"
|
|
||||||
else
|
|
||||||
platform.uname.processor;
|
|
||||||
in
|
|
||||||
builtins.toFile "lix-cross-file.conf" ''
|
|
||||||
[properties]
|
[properties]
|
||||||
# Meson is convinced that if !buildPlatform.canExecute hostPlatform then we cannot
|
# Meson is convinced that if !buildPlatform.canExecute hostPlatform then we cannot
|
||||||
# build anything at all, which is not at all correct. If we can't execute the host
|
# build anything at all, which is not at all correct. If we can't execute the host
|
||||||
|
|
|
@ -236,9 +236,9 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
futimes(bestSlotLock.get(), NULL);
|
futimes(bestSlotLock.get(), nullptr);
|
||||||
#else
|
#else
|
||||||
futimens(bestSlotLock.get(), NULL);
|
futimens(bestSlotLock.get(), nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lock.reset();
|
lock.reset();
|
||||||
|
|
|
@ -1882,7 +1882,7 @@ void LocalDerivationGoal::runChild()
|
||||||
sandboxArgs.push_back("_ALLOW_LOCAL_NETWORKING");
|
sandboxArgs.push_back("_ALLOW_LOCAL_NETWORKING");
|
||||||
sandboxArgs.push_back("1");
|
sandboxArgs.push_back("1");
|
||||||
}
|
}
|
||||||
if (sandbox_init_with_parameters(sandboxProfile.c_str(), 0, stringsToCharPtrs(sandboxArgs).data(), NULL)) {
|
if (sandbox_init_with_parameters(sandboxProfile.c_str(), 0, stringsToCharPtrs(sandboxArgs).data(), nullptr)) {
|
||||||
writeFull(STDERR_FILENO, "failed to configure sandbox\n");
|
writeFull(STDERR_FILENO, "failed to configure sandbox\n");
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,14 +177,14 @@ static bool hasVirt() {
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
size = sizeof(hasVMM);
|
size = sizeof(hasVMM);
|
||||||
if (sysctlbyname("kern.hv_vmm_present", &hasVMM, &size, NULL, 0) == 0) {
|
if (sysctlbyname("kern.hv_vmm_present", &hasVMM, &size, nullptr, 0) == 0) {
|
||||||
if (hasVMM)
|
if (hasVMM)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// whether the kernel and hardware supports virt
|
// whether the kernel and hardware supports virt
|
||||||
size = sizeof(hvSupport);
|
size = sizeof(hvSupport);
|
||||||
if (sysctlbyname("kern.hv_support", &hvSupport, &size, NULL, 0) == 0) {
|
if (sysctlbyname("kern.hv_support", &hvSupport, &size, nullptr, 0) == 0) {
|
||||||
return hvSupport == 1;
|
return hvSupport == 1;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -557,7 +557,7 @@ void LocalStore::openDB(State & state, bool create)
|
||||||
if (sqlite3_exec(db, "pragma main.journal_size_limit = 1099511627776;", 0, 0, 0) != SQLITE_OK)
|
if (sqlite3_exec(db, "pragma main.journal_size_limit = 1099511627776;", 0, 0, 0) != SQLITE_OK)
|
||||||
SQLiteError::throw_(db, "setting journal_size_limit");
|
SQLiteError::throw_(db, "setting journal_size_limit");
|
||||||
int enable = 1;
|
int enable = 1;
|
||||||
if (sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, &enable) != SQLITE_OK)
|
if (sqlite3_file_control(db, nullptr, SQLITE_FCNTL_PERSIST_WAL, &enable) != SQLITE_OK)
|
||||||
SQLiteError::throw_(db, "setting persistent WAL mode");
|
SQLiteError::throw_(db, "setting persistent WAL mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,15 +235,15 @@ void DarwinLocalDerivationGoal::execBuilder(std::string builder, Strings args, S
|
||||||
if (drv->platform == "aarch64-darwin") {
|
if (drv->platform == "aarch64-darwin") {
|
||||||
// Unset kern.curproc_arch_affinity so we can escape Rosetta
|
// Unset kern.curproc_arch_affinity so we can escape Rosetta
|
||||||
int affinity = 0;
|
int affinity = 0;
|
||||||
sysctlbyname("kern.curproc_arch_affinity", NULL, NULL, &affinity, sizeof(affinity));
|
sysctlbyname("kern.curproc_arch_affinity", nullptr, nullptr, &affinity, sizeof(affinity));
|
||||||
|
|
||||||
cpu_type_t cpu = CPU_TYPE_ARM64;
|
cpu_type_t cpu = CPU_TYPE_ARM64;
|
||||||
posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, NULL);
|
posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, nullptr);
|
||||||
} else if (drv->platform == "x86_64-darwin") {
|
} else if (drv->platform == "x86_64-darwin") {
|
||||||
cpu_type_t cpu = CPU_TYPE_X86_64;
|
cpu_type_t cpu = CPU_TYPE_X86_64;
|
||||||
posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, NULL);
|
posix_spawnattr_setbinpref_np(&attrp, 1, &cpu, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
posix_spawn(NULL, builder.c_str(), NULL, &attrp, stringsToCharPtrs(args).data(), stringsToCharPtrs(envStrs).data());
|
posix_spawn(nullptr, builder.c_str(), nullptr, &attrp, stringsToCharPtrs(args).data(), stringsToCharPtrs(envStrs).data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,23 +21,15 @@ Path absPath(Path path, std::optional<PathView> dir, bool resolveSymlinks)
|
||||||
{
|
{
|
||||||
if (path.empty() || path[0] != '/') {
|
if (path.empty() || path[0] != '/') {
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
#ifdef __GNU__
|
|
||||||
/* GNU (aka. GNU/Hurd) doesn't have any limitation on path
|
|
||||||
lengths and doesn't define `PATH_MAX'. */
|
|
||||||
char *buf = getcwd(NULL, 0);
|
|
||||||
if (buf == NULL)
|
|
||||||
#else
|
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
if (!getcwd(buf, sizeof(buf)))
|
if (!getcwd(buf, sizeof(buf))) {
|
||||||
#endif
|
|
||||||
throw SysError("cannot get cwd");
|
throw SysError("cannot get cwd");
|
||||||
|
}
|
||||||
path = concatStrings(buf, "/", path);
|
path = concatStrings(buf, "/", path);
|
||||||
#ifdef __GNU__
|
} else {
|
||||||
free(buf);
|
|
||||||
#endif
|
|
||||||
} else
|
|
||||||
path = concatStrings(*dir, "/", path);
|
path = concatStrings(*dir, "/", path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return canonPath(path, resolveSymlinks);
|
return canonPath(path, resolveSymlinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ TarArchive::TarArchive(Source & source, bool raw) : buffer(65536)
|
||||||
archive_read_support_format_raw(archive);
|
archive_read_support_format_raw(archive);
|
||||||
archive_read_support_format_empty(archive);
|
archive_read_support_format_empty(archive);
|
||||||
}
|
}
|
||||||
archive_read_set_option(archive, NULL, "mac-ext", NULL);
|
archive_read_set_option(archive, nullptr, "mac-ext", nullptr);
|
||||||
check(archive_read_open(archive, (void *)this, callback_open, callback_read, callback_close), "Failed to open archive (%s)");
|
check(archive_read_open(archive, (void *)this, callback_open, callback_read, callback_close), "Failed to open archive (%s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ TarArchive::TarArchive(const Path & path)
|
||||||
|
|
||||||
archive_read_support_filter_all(archive);
|
archive_read_support_filter_all(archive);
|
||||||
archive_read_support_format_all(archive);
|
archive_read_support_format_all(archive);
|
||||||
archive_read_set_option(archive, NULL, "mac-ext", NULL);
|
archive_read_set_option(archive, nullptr, "mac-ext", nullptr);
|
||||||
check(archive_read_open_filename(archive, path.c_str(), 16384), "failed to open archive: %s");
|
check(archive_read_open_filename(archive, path.c_str(), 16384), "failed to open archive: %s");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,24 +24,17 @@ GroupedPaths getClosureInfo(ref<Store> store, const StorePath & toplevel)
|
||||||
|
|
||||||
GroupedPaths groupedPaths;
|
GroupedPaths groupedPaths;
|
||||||
|
|
||||||
for (auto & path : closure) {
|
for (auto const & path : closure) {
|
||||||
/* Strip the output name. Unfortunately this is ambiguous (we
|
/* Strip the output name. Unfortunately this is ambiguous (we
|
||||||
can't distinguish between output names like "bin" and
|
can't distinguish between output names like "bin" and
|
||||||
version suffixes like "unstable"). */
|
version suffixes like "unstable"). */
|
||||||
static std::regex regex("(.*)-([a-z]+|lib32|lib64)");
|
static std::regex regex("(.*)-([a-z]+|lib32|lib64)");
|
||||||
std::smatch match;
|
std::cmatch match;
|
||||||
std::string name{path.name()};
|
std::string name{path.name()};
|
||||||
// Used to keep name alive through being potentially overwritten below
|
std::string_view const origName = path.name();
|
||||||
// (to not invalidate the references from the regex result)
|
|
||||||
//
|
|
||||||
// n.b. cannot be just path.name().{begin,end}() since that returns const
|
|
||||||
// char *, which does not, for some reason, convert as required on
|
|
||||||
// libstdc++. Seems like a libstdc++ bug or standard bug to me... we
|
|
||||||
// can afford the allocation in any case.
|
|
||||||
const std::string origName{path.name()};
|
|
||||||
std::string outputName;
|
std::string outputName;
|
||||||
|
|
||||||
if (std::regex_match(origName, match, regex)) {
|
if (std::regex_match(origName.begin(), origName.end(), match, regex)) {
|
||||||
name = match[1];
|
name = match[1];
|
||||||
outputName = match[2];
|
outputName = match[2];
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ std::set<std::string> runResolver(const Path & filename)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
char* obj = (char*) mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd.get(), 0);
|
char* obj = (char*) mmap(nullptr, st.st_size, PROT_READ, MAP_SHARED, fd.get(), 0);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
throw SysError("mmapping '%s'", filename);
|
throw SysError("mmapping '%s'", filename);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue