summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expand/proc_macro.cpp4
-rw-r--r--src/main.cpp12
-rw-r--r--src/trans/target.cpp28
3 files changed, 44 insertions, 0 deletions
diff --git a/src/expand/proc_macro.cpp b/src/expand/proc_macro.cpp
index 3eb0c85d..5c06a8ce 100644
--- a/src/expand/proc_macro.cpp
+++ b/src/expand/proc_macro.cpp
@@ -24,6 +24,10 @@
# include <sys/wait.h>
#endif
+#ifdef __OpenBSD__
+extern char **environ;
+#endif
+
#define NEWNODE(_ty, ...) ::AST::ExprNodeP(new ::AST::ExprNode##_ty(__VA_ARGS__))
class Decorator_ProcMacroDerive:
diff --git a/src/main.cpp b/src/main.cpp
index 5063a44b..479bbc14 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -52,6 +52,18 @@
# else
# define DEFAULT_TARGET_NAME "i586-windows-gnu"
# endif
+#elif defined(__OpenBSD__)
+# if defined(__amd64__)
+# define DEFAULT_TARGET_NAME "x86_64-unknown-openbsd"
+# elif defined(__aarch64__)
+# define DEFAULT_TARGET_NAME "arm64-unknown-openbsd"
+# elif defined(__arm__)
+# define DEFAULT_TARGET_NAME "arm-unknown-openbsd"
+# elif defined(__i386__)
+# define DEFAULT_TARGET_NAME "i686-unknown-openbsd"
+# else
+# error "Unable to detect a suitable default target (OpenBSD)"
+# endif
#else
# error "Unable to detect a suitable default target"
#endif
diff --git a/src/trans/target.cpp b/src/trans/target.cpp
index 71a342ba..1f04666e 100644
--- a/src/trans/target.cpp
+++ b/src/trans/target.cpp
@@ -94,6 +94,27 @@ namespace
ARCH_X86_64
};
}
+ else if(target_name == "i686-unknown-openbsd")
+ {
+ return TargetSpec {
+ "unix", "openbsd", "gnu", CodegenMode::Gnu11, "i686-unknown-openbsd",
+ ARCH_X86
+ };
+ }
+ else if(target_name == "x86_64-unknown-openbsd")
+ {
+ return TargetSpec {
+ "unix", "openbsd", "gnu", CodegenMode::Gnu11, "x86_64-unknown-openbsd",
+ ARCH_X86_64
+ };
+ }
+ else if(target_name == "arm-unknown-openbsd")
+ {
+ return TargetSpec {
+ "unix", "openbsd", "gnu", CodegenMode::Gnu11, "arm-unknown-openbsd",
+ ARCH_ARM32
+ };
+ }
else
{
::std::cerr << "Unknown target name '" << target_name << "'" << ::std::endl;
@@ -126,6 +147,13 @@ void Target_SetCfg(const ::std::string& target_name)
}
Cfg_SetValue("target_env", g_target.m_env_name);
+ if( g_target.m_os_name == "openbsd" )
+ {
+ Cfg_SetFlag("openbsd");
+ Cfg_SetValue("target_vendor", "unknown");
+ }
+ Cfg_SetValue("target_env", g_target.m_env_name);
+
Cfg_SetValue("target_os", g_target.m_os_name);
Cfg_SetValue("target_pointer_width", FMT(g_target.m_arch.m_pointer_bits));
Cfg_SetValue("target_endian", g_target.m_arch.m_big_endian ? "big" : "little");