Merge pull request #8887 from obsidiansystems/bsd-cross-ci

Support cross compiling to BSD and CI it

(cherry picked from commit 1f3fc08c5994ca69c84c9e745d59ec2bb2fd820a)
Change-Id: I415e92952afc661cfb5ef91a76c0637678a04a19
This commit is contained in:
John Ericson 2023-09-25 13:46:55 -04:00 committed by eldritch horrors
parent 2442a40393
commit bc4aa3d5db
4 changed files with 38 additions and 13 deletions

View file

@ -59,12 +59,18 @@ index b5d71e62..aed7b0bf 100644
GC_bool found_me = FALSE; GC_bool found_me = FALSE;
size_t nthreads = 0; size_t nthreads = 0;
int i; int i;
@@ -851,6 +853,31 @@ GC_INNER void GC_push_all_stacks(void) @@ -851,6 +853,37 @@ GC_INNER void GC_push_all_stacks(void)
hi = p->altstack + p->altstack_size; hi = p->altstack + p->altstack_size;
/* FIXME: Need to scan the normal stack too, but how ? */ /* FIXME: Need to scan the normal stack too, but how ? */
/* FIXME: Assume stack grows down */ /* FIXME: Assume stack grows down */
+ } else { + } else {
+ if (pthread_getattr_np(p->id, &pattr)) { +#ifdef HAVE_PTHREAD_ATTR_GET_NP
+ if (!pthread_attr_init(&pattr)
+ || !pthread_attr_get_np(p->id, &pattr))
+#else /* HAVE_PTHREAD_GETATTR_NP */
+ if (pthread_getattr_np(p->id, &pattr))
+#endif
+ {
+ ABORT("GC_push_all_stacks: pthread_getattr_np failed!"); + ABORT("GC_push_all_stacks: pthread_getattr_np failed!");
+ } + }
+ if (pthread_attr_getstacksize(&pattr, &stack_limit)) { + if (pthread_attr_getstacksize(&pattr, &stack_limit)) {

View file

@ -25,7 +25,10 @@
darwinSystems = [ "x86_64-darwin" "aarch64-darwin" ]; darwinSystems = [ "x86_64-darwin" "aarch64-darwin" ];
systems = linuxSystems ++ darwinSystems; systems = linuxSystems ++ darwinSystems;
crossSystems = [ "armv6l-linux" "armv7l-linux" ]; crossSystems = [
"armv6l-linux" "armv7l-linux"
"x86_64-freebsd13" "x86_64-netbsd"
];
stdenvs = [ "gccStdenv" "clangStdenv" "clang11Stdenv" "stdenv" "libcxxStdenv" "ccacheStdenv" ]; stdenvs = [ "gccStdenv" "clangStdenv" "clang11Stdenv" "stdenv" "libcxxStdenv" "ccacheStdenv" ];
@ -86,7 +89,14 @@
nixpkgsFor = forAllSystems nixpkgsFor = forAllSystems
(system: let (system: let
make-pkgs = crossSystem: stdenv: import nixpkgs { make-pkgs = crossSystem: stdenv: import nixpkgs {
inherit system crossSystem; localSystem = {
inherit system;
};
crossSystem = if crossSystem == null then null else {
system = crossSystem;
} // lib.optionalAttrs (crossSystem == "x86_64-freebsd13") {
useLLVM = true;
};
overlays = [ overlays = [
(overlayFor (p: p.${stdenv})) (overlayFor (p: p.${stdenv}))
]; ];
@ -172,9 +182,9 @@
libarchive libarchive
boost boost
lowdown-nix lowdown-nix
libsodium
] ]
++ lib.optionals stdenv.isLinux [libseccomp] ++ lib.optionals stdenv.isLinux [libseccomp]
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid; ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid;
checkDeps = [ checkDeps = [
@ -725,6 +735,9 @@
devShells = let devShells = let
makeShell = pkgs: stdenv: makeShell = pkgs: stdenv:
let
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
in
with commonDeps { inherit pkgs; }; with commonDeps { inherit pkgs; };
stdenv.mkDerivation { stdenv.mkDerivation {
name = "nix"; name = "nix";
@ -732,13 +745,18 @@
outputs = [ "out" "dev" "doc" ]; outputs = [ "out" "dev" "doc" ];
nativeBuildInputs = nativeBuildDeps nativeBuildInputs = nativeBuildDeps
++ (lib.optionals stdenv.cc.isClang [ pkgs.bear pkgs.clang-tools ]); ++ lib.optional stdenv.cc.isClang pkgs.buildPackages.bear
++ lib.optional
(stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform)
pkgs.buildPackages.clang-tools
;
buildInputs = buildDeps ++ propagatedDeps buildInputs = buildDeps ++ propagatedDeps
++ awsDeps ++ checkDeps ++ internalApiDocsDeps; ++ awsDeps ++ checkDeps ++ internalApiDocsDeps;
configureFlags = configureFlags configureFlags = configureFlags
++ testConfigureFlags ++ internalApiDocsConfigureFlags; ++ testConfigureFlags ++ internalApiDocsConfigureFlags
++ lib.optional (!canRunInstalled) "--disable-doc-gen";
enableParallelBuilding = true; enableParallelBuilding = true;

View file

@ -379,9 +379,9 @@ RunPager::RunPager()
}); });
pid.setKillSignal(SIGINT); pid.setKillSignal(SIGINT);
stdout = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 0); std_out = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 0);
if (dup2(toPager.writeSide.get(), STDOUT_FILENO) == -1) if (dup2(toPager.writeSide.get(), STDOUT_FILENO) == -1)
throw SysError("dupping stdout"); throw SysError("dupping standard output");
} }
@ -390,7 +390,7 @@ RunPager::~RunPager()
try { try {
if (pid != -1) { if (pid != -1) {
std::cout.flush(); std::cout.flush();
dup2(stdout, STDOUT_FILENO); dup2(std_out, STDOUT_FILENO);
pid.wait(); pid.wait();
} }
} catch (...) { } catch (...) {

View file

@ -85,8 +85,9 @@ struct LegacyArgs : public MixCommonArgs
void showManPage(const std::string & name); void showManPage(const std::string & name);
/** /**
* The constructor of this class starts a pager if stdout is a * The constructor of this class starts a pager if standard output is a
* terminal and $PAGER is set. Stdout is redirected to the pager. * terminal and $PAGER is set. Standard output is redirected to the
* pager.
*/ */
class RunPager class RunPager
{ {
@ -96,7 +97,7 @@ public:
private: private:
Pid pid; Pid pid;
int stdout; int std_out;
}; };
extern volatile ::sig_atomic_t blockInt; extern volatile ::sig_atomic_t blockInt;