Include config.h implicitly with '-include config.h' in CFLAGS

Because config.h can #define things like _FILE_OFFSET_BITS=64 and not
every compilation unit includes config.h, we currently compile half of
Nix with _FILE_OFFSET_BITS=64 and other half with _FILE_OFFSET_BITS
unset. This causes major havoc with the Settings class on e.g. 32-bit ARM,
where different compilation units disagree with the struct layout.

E.g.:

diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
@@ -166,6 +166,8 @@ void Settings::update()
     _get(useSubstitutes, "build-use-substitutes");
+    fprintf(stderr, "at Settings::update(): &useSubstitutes = %p\n", &nix::settings.useSubstitutes);
     _get(buildUsersGroup, "build-users-group");
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -138,6 +138,8 @@ void RemoteStore::initConnection(Connection & conn)
 void RemoteStore::setOptions(Connection & conn)
 {
+    fprintf(stderr, "at RemoteStore::setOptions(): &useSubstitutes = %p\n", &nix::settings.useSubstitutes);
     conn.to << wopSetOptions

Gave me:

at Settings::update(): &useSubstitutes = 0xb6e5c5cb
at RemoteStore::setOptions(): &useSubstitutes = 0xb6e5c5c7

That was not a fun one to debug!
This commit is contained in:
Tuomas Tynkkynen 2017-02-08 20:35:06 +02:00
parent 81c53fe8e5
commit 2cd468874f
15 changed files with 1 additions and 25 deletions

View file

@ -28,7 +28,7 @@ makefiles = \
doc/manual/local.mk \
tests/local.mk
GLOBAL_CXXFLAGS += -std=c++14 -g -Wall
GLOBAL_CXXFLAGS += -std=c++14 -g -Wall -include config.h
-include Makefile.config

View file

@ -1,4 +1,3 @@
#include "config.h"
#include "json-to-value.hh"
#include <cstring>

View file

@ -1,7 +1,5 @@
#pragma once
#include "config.h"
#include <map>
#include <unordered_set>

View file

@ -1,6 +1,5 @@
#pragma once
#include "config.h"
#include "symbol-table.hh"
#if HAVE_BOEHMGC

View file

@ -1,5 +1,3 @@
#include "config.h"
#include "common-args.hh"
#include "globals.hh"
#include "shared.hh"

View file

@ -1,5 +1,3 @@
#include "config.h"
#include "types.hh"
#include <cstring>

View file

@ -1,5 +1,3 @@
#include "config.h"
#include "references.hh"
#include "pathlocks.hh"
#include "globals.hh"

View file

@ -1,5 +1,3 @@
#include "config.h"
#include "globals.hh"
#include "util.hh"
#include "archive.hh"

View file

@ -1,4 +1,3 @@
#include "config.h"
#include "local-store.hh"
#include "globals.hh"
#include "archive.hh"

View file

@ -1,5 +1,3 @@
#include "config.h"
#include "util.hh"
#include "local-store.hh"
#include "globals.hh"

View file

@ -1,5 +1,3 @@
#include "config.h"
#if ENABLE_S3
#if __linux__

View file

@ -1,5 +1,3 @@
#include "config.h"
#include <cerrno>
#include <algorithm>
#include <vector>

View file

@ -1,5 +1,3 @@
#include "config.h"
#include <iostream>
#include <cstring>

View file

@ -1,6 +1,5 @@
#pragma once
#include "config.h"
#include "ref.hh"

View file

@ -1,5 +1,3 @@
#include "config.h"
#include "util.hh"
#include "affinity.hh"
#include "sync.hh"