From 9918d5c2612a5474cbcb16ee8d4ef11438565b39 Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Wed, 20 Sep 2017 07:25:06 +0000
Subject: [PATCH 1/4] Haiku: remove -Werror from compiler-rt build commands

---
 mk/cfg/i686-unknown-haiku.mk   | 2 +-
 mk/cfg/x86_64-unknown-haiku.mk | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mk/cfg/i686-unknown-haiku.mk b/mk/cfg/i686-unknown-haiku.mk
index cbacbff..d1bcc7a 100644
--- a/mk/cfg/i686-unknown-haiku.mk
+++ b/mk/cfg/i686-unknown-haiku.mk
@@ -9,7 +9,7 @@ CFG_STATIC_LIB_NAME_i686-unknown-haiku=lib$(1).a
 CFG_LIB_GLOB_i686-unknown-haiku=lib$(1)-*.so
 CFG_LIB_DSYM_GLOB_i686-unknown-haiku=lib$(1)-*.dylib.dSYM
 CFG_CFLAGS_i686-unknown-haiku := -m32 $(CFLAGS)
-CFG_GCCISH_CFLAGS_i686-unknown-haiku := -Wall -Werror -g -fPIC -m32 $(CFLAGS)
+CFG_GCCISH_CFLAGS_i686-unknown-haiku := -Wall -g -fPIC -m32 $(CFLAGS)
 CFG_GCCISH_CXXFLAGS_i686-unknown-haiku := -fno-rtti $(CXXFLAGS)
 CFG_GCCISH_LINK_FLAGS_i686-unknown-haiku := -shared -fPIC -ldl -pthread  -lrt -g -m32
 CFG_GCCISH_PRE_LIB_FLAGS_i686-unknown-haiku := -Wl,-whole-archive
diff --git a/mk/cfg/x86_64-unknown-haiku.mk b/mk/cfg/x86_64-unknown-haiku.mk
index 4c2d888..476327a 100644
--- a/mk/cfg/x86_64-unknown-haiku.mk
+++ b/mk/cfg/x86_64-unknown-haiku.mk
@@ -9,7 +9,7 @@ CFG_STATIC_LIB_NAME_x86_64-unknown-haiku=lib$(1).a
 CFG_LIB_GLOB_x86_64-unknown-haiku=lib$(1)-*.so
 CFG_LIB_DSYM_GLOB_x86_64-unknown-haiku=lib$(1)-*.dylib.dSYM
 CFG_CFLAGS_x86_64-unknown-haiku := -m64 $(CFLAGS)
-CFG_GCCISH_CFLAGS_x86_64-unknown-haiku := -Wall -Werror -g -fPIC -m64 $(CFLAGS)
+CFG_GCCISH_CFLAGS_x86_64-unknown-haiku := -Wall -g -fPIC -m64 $(CFLAGS)
 CFG_GCCISH_CXXFLAGS_x86_64-unknown-haiku := -fno-rtti $(CXXFLAGS)
 CFG_GCCISH_LINK_FLAGS_x86_64-unknown-haiku := -shared -fPIC -ldl -pthread -lrt -g -m64
 CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-haiku := -Wl,-whole-archive
-- 
2.7.0


From 19a7a308a5713dc4b71a058665f72ad4fc45fc53 Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Wed, 20 Sep 2017 07:26:48 +0000
Subject: [PATCH 2/4] Haiku: disable rpath as standard option on the compiler

---
 src/librustc_back/target/haiku_base.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librustc_back/target/haiku_base.rs b/src/librustc_back/target/haiku_base.rs
index 5e319ba..7f79330 100644
--- a/src/librustc_back/target/haiku_base.rs
+++ b/src/librustc_back/target/haiku_base.rs
@@ -16,7 +16,7 @@ pub fn opts() -> TargetOptions {
         linker: "cc".to_string(),
         dynamic_linking: true,
         executables: true,
-        has_rpath: true,
+        has_rpath: false,
         linker_is_gnu: true,
         .. Default::default()
     }
-- 
2.7.0


From 6ddec4cdb6ea6eebfca9f2fcf1c2c90b31811d5b Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Wed, 20 Sep 2017 07:27:38 +0000
Subject: [PATCH 3/4] Haiku: add missing F_RDLCK constant

---
 src/librustc_data_structures/flock.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs
index 510c9ce..c1546e0 100644
--- a/src/librustc_data_structures/flock.rs
+++ b/src/librustc_data_structures/flock.rs
@@ -109,6 +109,7 @@ mod imp {
             pub l_sysid: libc::c_int,
         }
 
+        pub const F_RDLCK: libc::c_short = 0x0040;
         pub const F_UNLCK: libc::c_short = 0x0200;
         pub const F_WRLCK: libc::c_short = 0x0400;
         pub const F_SETLK: libc::c_int = 0x0080;
-- 
2.7.0


From e2986a4d189cc122ab29c93d2e7a6b0e71f1cf90 Mon Sep 17 00:00:00 2001
From: Niels Sascha Reedijk <niels.reedijk@gmail.com>
Date: Wed, 20 Sep 2017 17:36:59 +0000
Subject: [PATCH 4/4] Haiku: reduce stack memory to 16MB (max on Haiku)

---
 src/librustdoc/lib.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index ee395e0..75ae3be 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -98,7 +98,7 @@ struct Output {
 }
 
 pub fn main() {
-    const STACK_SIZE: usize = 32_000_000; // 32MB
+    const STACK_SIZE: usize = 16_000_000; // 16MB on Haiku
     let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
         let s = env::args().collect::<Vec<_>>();
         main_args(&s)
-- 
2.7.0

