1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-15 15:02:42 +01:00

Add -Wundef to make #if FOO an error if not defined

This commit has all the straightforward stuff.
This commit is contained in:
Robert Hensing 2025-04-05 00:45:19 +02:00
parent cb972c789a
commit 59ced3da96
23 changed files with 40 additions and 33 deletions

View file

@ -8,6 +8,7 @@
#include "nix/util/callback.hh"
#include "nix/util/signals.hh"
#include "store-config-private.hh"
#if ENABLE_S3
#include <aws/core/client/ClientConfiguration.h>
#endif

View file

@ -25,7 +25,7 @@
# include <dlfcn.h>
#endif
#if __APPLE__
#ifdef __APPLE__
# include "nix/util/processes.hh"
#endif
@ -90,7 +90,7 @@ Settings::Settings()
#endif
/* chroot-like behavior from Apple's sandbox */
#if __APPLE__
#ifdef __APPLE__
sandboxPaths = tokenizeString<StringSet>("/System/Library/Frameworks /System/Library/PrivateFrameworks /bin/sh /bin/bash /private/tmp /private/var/tmp /usr/lib");
allowedImpureHostPrefixes = tokenizeString<StringSet>("/System/Library /usr/lib /dev /bin/sh");
#endif
@ -151,7 +151,7 @@ unsigned int Settings::getDefaultCores()
return concurrency;
}
#if __APPLE__
#ifdef __APPLE__
static bool hasVirt() {
int hasVMM;
@ -190,7 +190,7 @@ StringSet Settings::getDefaultSystemFeatures()
features.insert("kvm");
#endif
#if __APPLE__
#ifdef __APPLE__
if (hasVirt())
features.insert("apple-virt");
#endif
@ -374,7 +374,7 @@ void initLibStore(bool loadConfig) {
[1] https://github.com/apple-oss-distributions/objc4/blob/01edf1705fbc3ff78a423cd21e03dfc21eb4d780/runtime/objc-initialize.mm#L614-L636
*/
curl_global_init(CURL_GLOBAL_ALL);
#if __APPLE__
#ifdef __APPLE__
/* On macOS, don't use the per-session TMPDIR (as set e.g. by
sshd). This breaks build users because they don't have access
to the TMPDIR, in particular in nix-store --serve. */

View file

@ -708,7 +708,7 @@ public:
Setting<PathSet> allowedImpureHostPrefixes{this, {}, "allowed-impure-host-deps",
"Which prefixes to allow derivations to ask for access to (primarily for Darwin)."};
#if __APPLE__
#ifdef __APPLE__
Setting<bool> darwinLogSandboxViolations{this, false, "darwin-log-sandbox-violations",
"Whether to log Darwin sandbox access violations to the system log."};
#endif

View file

@ -1,6 +1,6 @@
#pragma once
///@file
#include "store-config-private.hh"
#if ENABLE_S3
#include "nix/util/ref.hh"

View file

@ -13,6 +13,7 @@
#include <stdio.h>
#include <regex>
#include "store-config-private.hh"
namespace nix {
@ -96,7 +97,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
auto st = lstat(path);
#if __APPLE__
#ifdef __APPLE__
/* HFS/macOS has some undocumented security feature disabling hardlinking for
special files within .app dirs. Known affected paths include
*.app/Contents/{PkgInfo,Resources/\*.lproj,_CodeSignature} and .DS_Store.

View file

@ -58,7 +58,7 @@ static void canonicalisePathMetaData_(
{
checkInterrupt();
#if __APPLE__
#ifdef __APPLE__
/* Remove flags, in particular UF_IMMUTABLE which would prevent
the file from being garbage-collected. FIXME: Use
setattrlist() to remove other attributes as well. */

View file

@ -1,3 +1,4 @@
#include "store-config-private.hh"
#if ENABLE_S3
#include <assert.h>

View file

@ -61,7 +61,7 @@
# include "nix/store/personality.hh"
#endif
#if __APPLE__
#ifdef __APPLE__
#include <spawn.h>
#include <sys/sysctl.h>
#include <sandbox.h>
@ -77,6 +77,8 @@ extern "C" int sandbox_init_with_parameters(const char *profile, uint64_t flags,
#include "nix/util/strings.hh"
#include "nix/util/signals.hh"
#include "store-config-private.hh"
namespace nix {
struct LocalDerivationGoal : DerivationGoal, RestrictionContext
@ -496,7 +498,7 @@ Goal::Co LocalDerivationGoal::tryLocalBuild()
if (drvOptions->noChroot)
throw Error("derivation '%s' has '__noChroot' set, "
"but that's not allowed when 'sandbox' is 'true'", worker.store.printStorePath(drvPath));
#if __APPLE__
#ifdef __APPLE__
if (drvOptions->additionalSandboxProfile != "")
throw Error("derivation '%s' specifies a sandbox profile, "
"but this is only allowed when 'sandbox' is 'relaxed'", worker.store.printStorePath(drvPath));
@ -890,7 +892,7 @@ void LocalDerivationGoal::startBuilder()
/* Create a temporary directory where the build will take
place. */
topTmpDir = createTempDir(settings.buildDir.get().value_or(""), "nix-build-" + std::string(drvPath.name()), false, false, 0700);
#if __APPLE__
#ifdef __APPLE__
if (false) {
#else
if (useChroot) {
@ -1168,7 +1170,7 @@ void LocalDerivationGoal::startBuilder()
#else
if (drvOptions->useUidRange(*drv))
throw Error("feature 'uid-range' is not supported on this platform");
#if __APPLE__
#ifdef __APPLE__
/* We don't really have any parent prep work to do (yet?)
All work happens in the child, instead. */
#else
@ -1248,7 +1250,7 @@ void LocalDerivationGoal::startBuilder()
if (chown(slaveName.c_str(), buildUser->getUID(), 0))
throw SysError("changing owner of pseudoterminal slave");
}
#if __APPLE__
#ifdef __APPLE__
else {
if (grantpt(builderOut.get()))
throw SysError("granting access to pseudoterminal slave");
@ -2015,7 +2017,7 @@ void LocalDerivationGoal::runChild()
for (auto & i : pathsInChroot) {
if (i.second.source == "/proc") continue; // backwards compatibility
#if HAVE_EMBEDDED_SANDBOX_SHELL
#ifdef HAVE_EMBEDDED_SANDBOX_SHELL
if (i.second.source == "__embedded_sandbox_shell__") {
static unsigned char sh[] = {
#include "embedded-sandbox-shell.gen.hh"
@ -2169,7 +2171,7 @@ void LocalDerivationGoal::runChild()
throw SysError("setuid failed");
}
#if __APPLE__
#ifdef __APPLE__
/* This has to appear before import statements. */
std::string sandboxProfile = "(version 1)\n";
@ -2340,7 +2342,7 @@ void LocalDerivationGoal::runChild()
for (auto & i : drv->args)
args.push_back(rewriteStrings(i, inputRewrites));
#if __APPLE__
#ifdef __APPLE__
posix_spawnattr_t attrp;
if (posix_spawnattr_init(&attrp))