aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-11-27 14:17:15 +0100
committerEelco Dolstra <edolstra@gmail.com>2019-11-27 14:17:15 +0100
commit949dc848940b68ffd1327a278df4472e98a455dc (patch)
tree60bbeea2a0b097c0a52b5b9a37b80ccf4d39dd5b /src
parentdbc4f9d478814f3ce4ee23531502247d02c85911 (diff)
Fix segfault on i686-linux
https://hydra.nixos.org/build/107467517 Seems that on i686-linux, gcc and rustc disagree on how to return 1-word structs: gcc has the caller pass a pointer to the result, while rustc has the callee return the result in a register. Work around this by using a bare pointer.
Diffstat (limited to 'src')
-rw-r--r--src/libutil/rust-ffi.hh13
-rw-r--r--src/libutil/tarfile.cc6
2 files changed, 4 insertions, 15 deletions
diff --git a/src/libutil/rust-ffi.hh b/src/libutil/rust-ffi.hh
index a488b96d6..663758bfc 100644
--- a/src/libutil/rust-ffi.hh
+++ b/src/libutil/rust-ffi.hh
@@ -81,17 +81,4 @@ struct CBox
}
};
-// Grrr, this is only needed because 'extern "C"' functions don't
-// support non-POD return types (and CBox has a destructor so it's not
-// POD).
-template<typename T>
-struct CBox2
-{
- T * ptr;
- CBox<T> use()
- {
- return CBox(ptr);
- }
-};
-
}
diff --git a/src/libutil/tarfile.cc b/src/libutil/tarfile.cc
index f7d3ad417..2cc7793fd 100644
--- a/src/libutil/tarfile.cc
+++ b/src/libutil/tarfile.cc
@@ -2,14 +2,16 @@
#include "compression.hh"
extern "C" {
- rust::CBox2<rust::Result<std::tuple<>>> unpack_tarfile(rust::Source source, rust::StringSlice dest_dir);
+ rust::Result<std::tuple<>> *
+ unpack_tarfile(rust::Source source, rust::StringSlice dest_dir);
}
namespace nix {
void unpackTarfile(Source & source, const Path & destDir)
{
- unpack_tarfile(source, destDir).use()->unwrap();
+ rust::Source source2(source);
+ rust::CBox(unpack_tarfile(source2, destDir))->unwrap();
}
void unpackTarfile(const Path & tarFile, const Path & destDir,