Skip to content

Commit

Permalink
Merge pull request #8887 from obsidiansystems/bsd-cross-ci
Browse files Browse the repository at this point in the history
Support cross compiling to BSD and CI it
  • Loading branch information
Ericson2314 authored Sep 25, 2023
2 parents b21c415 + c189116 commit 1f3fc08
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
10 changes: 8 additions & 2 deletions boehmgc-coroutine-sp-fallback.diff
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ index b5d71e62..aed7b0bf 100644
GC_bool found_me = FALSE;
size_t nthreads = 0;
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;
/* FIXME: Need to scan the normal stack too, but how ? */
/* FIXME: Assume stack grows down */
+ } 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!");
+ }
+ if (pthread_attr_getstacksize(&pattr, &stack_limit)) {
Expand Down
30 changes: 24 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
linuxSystems = linux32BitSystems ++ linux64BitSystems;
darwinSystems = [ "x86_64-darwin" "aarch64-darwin" ];
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" ];

Expand Down Expand Up @@ -93,7 +96,14 @@
nixpkgsFor = forAllSystems
(system: let
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 = [
(overlayFor (p: p.${stdenv}))
];
Expand Down Expand Up @@ -179,9 +189,9 @@
libarchive
boost
lowdown-nix
libsodium
]
++ lib.optionals stdenv.isLinux [libseccomp]
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid;

checkDeps = [
Expand Down Expand Up @@ -732,20 +742,28 @@

devShells = let
makeShell = pkgs: stdenv:
let
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
in
with commonDeps { inherit pkgs; };
stdenv.mkDerivation {
name = "nix";

outputs = [ "out" "dev" "doc" ];

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
++ awsDeps ++ checkDeps ++ internalApiDocsDeps;

configureFlags = configureFlags
++ testConfigureFlags ++ internalApiDocsConfigureFlags;
++ testConfigureFlags ++ internalApiDocsConfigureFlags
++ lib.optional (!canRunInstalled) "--disable-doc-gen";

enableParallelBuilding = true;

Expand Down
6 changes: 3 additions & 3 deletions src/libmain/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ RunPager::RunPager()
});

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)
throw SysError("dupping stdout");
throw SysError("dupping standard output");
}


Expand All @@ -390,7 +390,7 @@ RunPager::~RunPager()
try {
if (pid != -1) {
std::cout.flush();
dup2(stdout, STDOUT_FILENO);
dup2(std_out, STDOUT_FILENO);
pid.wait();
}
} catch (...) {
Expand Down
7 changes: 4 additions & 3 deletions src/libmain/shared.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ struct LegacyArgs : public MixCommonArgs
void showManPage(const std::string & name);

/**
* The constructor of this class starts a pager if stdout is a
* terminal and $PAGER is set. Stdout is redirected to the pager.
* The constructor of this class starts a pager if standard output is a
* terminal and $PAGER is set. Standard output is redirected to the
* pager.
*/
class RunPager
{
Expand All @@ -96,7 +97,7 @@ public:

private:
Pid pid;
int stdout;
int std_out;
};

extern volatile ::sig_atomic_t blockInt;
Expand Down

0 comments on commit 1f3fc08

Please sign in to comment.