mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
Add -Wundef to make #if FOO an error if not defined
This commit has all the straightforward stuff.
This commit is contained in:
parent
cb972c789a
commit
59ced3da96
23 changed files with 40 additions and 33 deletions
|
@ -10,6 +10,7 @@ add_project_arguments(
|
||||||
'-Werror=suggest-override',
|
'-Werror=suggest-override',
|
||||||
'-Werror=switch',
|
'-Werror=switch',
|
||||||
'-Werror=switch-enum',
|
'-Werror=switch-enum',
|
||||||
|
'-Werror=undef',
|
||||||
'-Werror=unused-result',
|
'-Werror=unused-result',
|
||||||
'-Werror=sign-compare',
|
'-Werror=sign-compare',
|
||||||
'-Wignored-qualifiers',
|
'-Wignored-qualifiers',
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
futimes(bestSlotLock.get(), NULL);
|
futimes(bestSlotLock.get(), NULL);
|
||||||
#else
|
#else
|
||||||
futimens(bestSlotLock.get(), NULL);
|
futimens(bestSlotLock.get(), NULL);
|
||||||
|
|
|
@ -27,7 +27,7 @@ int main (int argc, char **argv) {
|
||||||
settings.sandboxBuildDir = "/test-build-dir-instead-of-usual-build-dir";
|
settings.sandboxBuildDir = "/test-build-dir-instead-of-usual-build-dir";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
// Avoid this error, when already running in a sandbox:
|
// Avoid this error, when already running in a sandbox:
|
||||||
// sandbox-exec: sandbox_apply: Operation not permitted
|
// sandbox-exec: sandbox_apply: Operation not permitted
|
||||||
settings.sandboxMode = smDisabled;
|
settings.sandboxMode = smDisabled;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#if NIX_USE_BOEHMGC
|
#if NIX_USE_BOEHMGC
|
||||||
|
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# if __FreeBSD__
|
# ifdef __FreeBSD__
|
||||||
# include <pthread_np.h>
|
# include <pthread_np.h>
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "nix/util/strings.hh"
|
#include "nix/util/strings.hh"
|
||||||
|
|
||||||
#include "main-config-private.hh"
|
#include "main-config-private.hh"
|
||||||
|
#include "nix/expr/config.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ void initNix(bool loadConfig)
|
||||||
if (sigaction(SIGUSR1, &act, 0)) throw SysError("handling SIGUSR1");
|
if (sigaction(SIGUSR1, &act, 0)) throw SysError("handling SIGUSR1");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
/* HACK: on darwin, we need can’t use sigprocmask with SIGWINCH.
|
/* HACK: on darwin, we need can’t use sigprocmask with SIGWINCH.
|
||||||
* Instead, add a dummy sigaction handler, and signalHandlerThread
|
* Instead, add a dummy sigaction handler, and signalHandlerThread
|
||||||
* can handle the rest. */
|
* can handle the rest. */
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "store-tests-config.hh"
|
||||||
#if ENABLE_S3
|
#if ENABLE_S3
|
||||||
|
|
||||||
# include <gtest/gtest.h>
|
# include <gtest/gtest.h>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "nix/util/callback.hh"
|
#include "nix/util/callback.hh"
|
||||||
#include "nix/util/signals.hh"
|
#include "nix/util/signals.hh"
|
||||||
|
|
||||||
|
#include "store-config-private.hh"
|
||||||
#if ENABLE_S3
|
#if ENABLE_S3
|
||||||
#include <aws/core/client/ClientConfiguration.h>
|
#include <aws/core/client/ClientConfiguration.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
# include <dlfcn.h>
|
# include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
# include "nix/util/processes.hh"
|
# include "nix/util/processes.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ Settings::Settings()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* chroot-like behavior from Apple's sandbox */
|
/* 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");
|
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");
|
allowedImpureHostPrefixes = tokenizeString<StringSet>("/System/Library /usr/lib /dev /bin/sh");
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,7 +151,7 @@ unsigned int Settings::getDefaultCores()
|
||||||
return concurrency;
|
return concurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
static bool hasVirt() {
|
static bool hasVirt() {
|
||||||
|
|
||||||
int hasVMM;
|
int hasVMM;
|
||||||
|
@ -190,7 +190,7 @@ StringSet Settings::getDefaultSystemFeatures()
|
||||||
features.insert("kvm");
|
features.insert("kvm");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
if (hasVirt())
|
if (hasVirt())
|
||||||
features.insert("apple-virt");
|
features.insert("apple-virt");
|
||||||
#endif
|
#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
|
[1] https://github.com/apple-oss-distributions/objc4/blob/01edf1705fbc3ff78a423cd21e03dfc21eb4d780/runtime/objc-initialize.mm#L614-L636
|
||||||
*/
|
*/
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
/* On macOS, don't use the per-session TMPDIR (as set e.g. by
|
/* 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
|
sshd). This breaks build users because they don't have access
|
||||||
to the TMPDIR, in particular in ‘nix-store --serve’. */
|
to the TMPDIR, in particular in ‘nix-store --serve’. */
|
||||||
|
|
|
@ -708,7 +708,7 @@ public:
|
||||||
Setting<PathSet> allowedImpureHostPrefixes{this, {}, "allowed-impure-host-deps",
|
Setting<PathSet> allowedImpureHostPrefixes{this, {}, "allowed-impure-host-deps",
|
||||||
"Which prefixes to allow derivations to ask for access to (primarily for Darwin)."};
|
"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",
|
Setting<bool> darwinLogSandboxViolations{this, false, "darwin-log-sandbox-violations",
|
||||||
"Whether to log Darwin sandbox access violations to the system log."};
|
"Whether to log Darwin sandbox access violations to the system log."};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
#include "store-config-private.hh"
|
||||||
#if ENABLE_S3
|
#if ENABLE_S3
|
||||||
|
|
||||||
#include "nix/util/ref.hh"
|
#include "nix/util/ref.hh"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
|
||||||
|
|
||||||
auto st = lstat(path);
|
auto st = lstat(path);
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
/* HFS/macOS has some undocumented security feature disabling hardlinking for
|
/* HFS/macOS has some undocumented security feature disabling hardlinking for
|
||||||
special files within .app dirs. Known affected paths include
|
special files within .app dirs. Known affected paths include
|
||||||
*.app/Contents/{PkgInfo,Resources/\*.lproj,_CodeSignature} and .DS_Store.
|
*.app/Contents/{PkgInfo,Resources/\*.lproj,_CodeSignature} and .DS_Store.
|
||||||
|
|
|
@ -58,7 +58,7 @@ static void canonicalisePathMetaData_(
|
||||||
{
|
{
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
/* Remove flags, in particular UF_IMMUTABLE which would prevent
|
/* Remove flags, in particular UF_IMMUTABLE which would prevent
|
||||||
the file from being garbage-collected. FIXME: Use
|
the file from being garbage-collected. FIXME: Use
|
||||||
setattrlist() to remove other attributes as well. */
|
setattrlist() to remove other attributes as well. */
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "store-config-private.hh"
|
||||||
#if ENABLE_S3
|
#if ENABLE_S3
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
# include "nix/store/personality.hh"
|
# include "nix/store/personality.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sandbox.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/strings.hh"
|
||||||
#include "nix/util/signals.hh"
|
#include "nix/util/signals.hh"
|
||||||
|
|
||||||
|
#include "store-config-private.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
struct LocalDerivationGoal : DerivationGoal, RestrictionContext
|
struct LocalDerivationGoal : DerivationGoal, RestrictionContext
|
||||||
|
@ -496,7 +498,7 @@ Goal::Co LocalDerivationGoal::tryLocalBuild()
|
||||||
if (drvOptions->noChroot)
|
if (drvOptions->noChroot)
|
||||||
throw Error("derivation '%s' has '__noChroot' set, "
|
throw Error("derivation '%s' has '__noChroot' set, "
|
||||||
"but that's not allowed when 'sandbox' is 'true'", worker.store.printStorePath(drvPath));
|
"but that's not allowed when 'sandbox' is 'true'", worker.store.printStorePath(drvPath));
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
if (drvOptions->additionalSandboxProfile != "")
|
if (drvOptions->additionalSandboxProfile != "")
|
||||||
throw Error("derivation '%s' specifies a sandbox profile, "
|
throw Error("derivation '%s' specifies a sandbox profile, "
|
||||||
"but this is only allowed when 'sandbox' is 'relaxed'", worker.store.printStorePath(drvPath));
|
"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
|
/* Create a temporary directory where the build will take
|
||||||
place. */
|
place. */
|
||||||
topTmpDir = createTempDir(settings.buildDir.get().value_or(""), "nix-build-" + std::string(drvPath.name()), false, false, 0700);
|
topTmpDir = createTempDir(settings.buildDir.get().value_or(""), "nix-build-" + std::string(drvPath.name()), false, false, 0700);
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
if (false) {
|
if (false) {
|
||||||
#else
|
#else
|
||||||
if (useChroot) {
|
if (useChroot) {
|
||||||
|
@ -1168,7 +1170,7 @@ void LocalDerivationGoal::startBuilder()
|
||||||
#else
|
#else
|
||||||
if (drvOptions->useUidRange(*drv))
|
if (drvOptions->useUidRange(*drv))
|
||||||
throw Error("feature 'uid-range' is not supported on this platform");
|
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?)
|
/* We don't really have any parent prep work to do (yet?)
|
||||||
All work happens in the child, instead. */
|
All work happens in the child, instead. */
|
||||||
#else
|
#else
|
||||||
|
@ -1248,7 +1250,7 @@ void LocalDerivationGoal::startBuilder()
|
||||||
if (chown(slaveName.c_str(), buildUser->getUID(), 0))
|
if (chown(slaveName.c_str(), buildUser->getUID(), 0))
|
||||||
throw SysError("changing owner of pseudoterminal slave");
|
throw SysError("changing owner of pseudoterminal slave");
|
||||||
}
|
}
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
else {
|
else {
|
||||||
if (grantpt(builderOut.get()))
|
if (grantpt(builderOut.get()))
|
||||||
throw SysError("granting access to pseudoterminal slave");
|
throw SysError("granting access to pseudoterminal slave");
|
||||||
|
@ -2015,7 +2017,7 @@ void LocalDerivationGoal::runChild()
|
||||||
for (auto & i : pathsInChroot) {
|
for (auto & i : pathsInChroot) {
|
||||||
if (i.second.source == "/proc") continue; // backwards compatibility
|
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__") {
|
if (i.second.source == "__embedded_sandbox_shell__") {
|
||||||
static unsigned char sh[] = {
|
static unsigned char sh[] = {
|
||||||
#include "embedded-sandbox-shell.gen.hh"
|
#include "embedded-sandbox-shell.gen.hh"
|
||||||
|
@ -2169,7 +2171,7 @@ void LocalDerivationGoal::runChild()
|
||||||
throw SysError("setuid failed");
|
throw SysError("setuid failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
/* This has to appear before import statements. */
|
/* This has to appear before import statements. */
|
||||||
std::string sandboxProfile = "(version 1)\n";
|
std::string sandboxProfile = "(version 1)\n";
|
||||||
|
|
||||||
|
@ -2340,7 +2342,7 @@ void LocalDerivationGoal::runChild()
|
||||||
for (auto & i : drv->args)
|
for (auto & i : drv->args)
|
||||||
args.push_back(rewriteStrings(i, inputRewrites));
|
args.push_back(rewriteStrings(i, inputRewrites));
|
||||||
|
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
posix_spawnattr_t attrp;
|
posix_spawnattr_t attrp;
|
||||||
|
|
||||||
if (posix_spawnattr_init(&attrp))
|
if (posix_spawnattr_init(&attrp))
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace nix {
|
||||||
struct ArchiveSettings : Config
|
struct ArchiveSettings : Config
|
||||||
{
|
{
|
||||||
Setting<bool> useCaseHack{this,
|
Setting<bool> useCaseHack{this,
|
||||||
#if __APPLE__
|
#ifdef __APPLE__
|
||||||
true,
|
true,
|
||||||
#else
|
#else
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -98,7 +98,7 @@ void AutoCloseFD::fsync() const
|
||||||
result =
|
result =
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
::FlushFileBuffers(fd)
|
::FlushFileBuffers(fd)
|
||||||
#elif __APPLE__
|
#elif defined(__APPLE__)
|
||||||
::fcntl(fd, F_FULLFSYNC)
|
::fcntl(fd, F_FULLFSYNC)
|
||||||
#else
|
#else
|
||||||
::fsync(fd)
|
::fsync(fd)
|
||||||
|
|
|
@ -576,7 +576,7 @@ Path createTempDir(const Path & tmpRoot, const Path & prefix,
|
||||||
, mode
|
, mode
|
||||||
#endif
|
#endif
|
||||||
) == 0) {
|
) == 0) {
|
||||||
#if __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
/* Explicitly set the group of the directory. This is to
|
/* Explicitly set the group of the directory. This is to
|
||||||
work around around problems caused by BSD's group
|
work around around problems caused by BSD's group
|
||||||
ownership semantics (directories inherit the group of
|
ownership semantics (directories inherit the group of
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "nix/util/config-global.hh"
|
#include "nix/util/config-global.hh"
|
||||||
#include "nix/util/fs-sink.hh"
|
#include "nix/util/fs-sink.hh"
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# include <fileapi.h>
|
# include <fileapi.h>
|
||||||
# include "nix/util/file-path.hh"
|
# include "nix/util/file-path.hh"
|
||||||
# include "nix/util/windows-error.hh"
|
# include "nix/util/windows-error.hh"
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct Source;
|
||||||
* Operating System capability
|
* Operating System capability
|
||||||
*/
|
*/
|
||||||
using Descriptor =
|
using Descriptor =
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE
|
HANDLE
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
|
@ -26,7 +26,7 @@ using Descriptor =
|
||||||
;
|
;
|
||||||
|
|
||||||
const Descriptor INVALID_DESCRIPTOR =
|
const Descriptor INVALID_DESCRIPTOR =
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
INVALID_HANDLE_VALUE
|
INVALID_HANDLE_VALUE
|
||||||
#else
|
#else
|
||||||
-1
|
-1
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "nix/util/environment-variables.hh"
|
#include "nix/util/environment-variables.hh"
|
||||||
#include "nix/util/sync.hh"
|
#include "nix/util/sync.hh"
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
|
|
@ -78,7 +78,7 @@ int Pid::kill()
|
||||||
/* On BSDs, killing a process group will return EPERM if all
|
/* On BSDs, killing a process group will return EPERM if all
|
||||||
processes in the group are zombies (or something like
|
processes in the group are zombies (or something like
|
||||||
that). So try to detect and ignore that situation. */
|
that). So try to detect and ignore that situation. */
|
||||||
#if __FreeBSD__ || __APPLE__
|
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||||
if (errno != EPERM || ::kill(pid, 0) != 0)
|
if (errno != EPERM || ::kill(pid, 0) != 0)
|
||||||
#endif
|
#endif
|
||||||
logError(SysError("killing process %d", pid).info());
|
logError(SysError("killing process %d", pid).info());
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// Darwin and FreeBSD stdenv do not define _GNU_SOURCE but do have _Unwind_Backtrace.
|
// Darwin and FreeBSD stdenv do not define _GNU_SOURCE but do have _Unwind_Backtrace.
|
||||||
#if __APPLE__ || __FreeBSD__
|
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||||
# define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
|
# define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "nix/util/cgroup.hh"
|
#include "nix/util/cgroup.hh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __APPLE__ || __FreeBSD__
|
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||||
#include <sys/ucred.h>
|
#include <sys/ucred.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue