aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2020-04-29 22:25:56 +0800
committerPhilip Herron <philip.herron@embecosm.com>2020-11-27 17:54:43 +0000
commit89d78a4a9e0af7e4a7da88c3e6d7688b8423fc39 (patch)
tree6f1bdd1945ce974ba5e1f7c56f968b6974dcc126
parent3835d919db31892b755396b5ed8cf1257204389d (diff)
downloadgcc-89d78a4a9e0af7e4a7da88c3e6d7688b8423fc39.zip
gcc-89d78a4a9e0af7e4a7da88c3e6d7688b8423fc39.tar.gz
gcc-89d78a4a9e0af7e4a7da88c3e6d7688b8423fc39.tar.bz2
Initial target hook construction
Creation of basic target_os, target_env, target_vendor, and target_family for all GCC targets. Also target_cpu and target_features for i386 - will do target_features for other targets when I can find exactly what is considered a target_feature by rustc
-rw-r--r--gcc/config/aarch64/aarch64-freebsd.h8
-rw-r--r--gcc/config/aarch64/aarch64-linux.h9
-rw-r--r--gcc/config/aarch64/aarch64-netbsd.h8
-rw-r--r--gcc/config/aarch64/aarch64-vxworks.h8
-rw-r--r--gcc/config/aarch64/rtems.h13
-rw-r--r--gcc/config/alpha/linux.h8
-rw-r--r--gcc/config/alpha/netbsd.h4
-rw-r--r--gcc/config/alpha/openbsd.h5
-rw-r--r--gcc/config/alpha/vms.h3
-rw-r--r--gcc/config/arc/linux.h71
-rw-r--r--gcc/config/arm/bpabi.h11
-rw-r--r--gcc/config/arm/freebsd.h9
-rw-r--r--gcc/config/arm/linux-eabi.h8
-rw-r--r--gcc/config/arm/linux-elf.h5
-rw-r--r--gcc/config/arm/netbsd-eabi.h10
-rw-r--r--gcc/config/arm/netbsd-elf.h8
-rw-r--r--gcc/config/arm/rtems.h14
-rw-r--r--gcc/config/arm/symbian.h15
-rw-r--r--gcc/config/arm/uclinux-eabi.h13
-rw-r--r--gcc/config/arm/uclinux-elf.h12
-rw-r--r--gcc/config/arm/vxworks.h14
-rw-r--r--gcc/config/bfin/linux.h5
-rw-r--r--gcc/config/bfin/rtems.h10
-rw-r--r--gcc/config/bfin/uclinux.h2
-rw-r--r--gcc/config/c6x/uclinux-elf.h12
-rw-r--r--gcc/config/csky/csky-linux-elf.h5
-rw-r--r--gcc/config/dragonfly.h12
-rw-r--r--gcc/config/epiphany/rtems.h13
-rw-r--r--gcc/config/freebsd-spec.h9
-rw-r--r--gcc/config/freebsd.h5
-rw-r--r--gcc/config/frv/linux.h8
-rw-r--r--gcc/config/fuchsia.h16
-rw-r--r--gcc/config/gnu.h9
-rw-r--r--gcc/config/h8300/linux.h5
-rw-r--r--gcc/config/i386/crtdll.h12
-rw-r--r--gcc/config/i386/cygming.h5
-rw-r--r--gcc/config/i386/cygwin.h10
-rw-r--r--gcc/config/i386/darwin.h10
-rw-r--r--gcc/config/i386/djgpp.h9
-rw-r--r--gcc/config/i386/gnu-user-common.h5
-rw-r--r--gcc/config/i386/i386-rust.c236
-rw-r--r--gcc/config/i386/i386.h3
-rw-r--r--gcc/config/i386/linux-common.h11
-rw-r--r--gcc/config/i386/lynx.h9
-rw-r--r--gcc/config/i386/mingw32.h8
-rw-r--r--gcc/config/i386/netbsd-elf.h5
-rw-r--r--gcc/config/i386/netbsd64.h5
-rw-r--r--gcc/config/i386/nto.h12
-rw-r--r--gcc/config/i386/openbsdelf.h5
-rw-r--r--gcc/config/i386/rdos.h11
-rw-r--r--gcc/config/i386/rtemself.h10
-rw-r--r--gcc/config/i386/t-i3864
-rw-r--r--gcc/config/i386/vxworks.h5
-rw-r--r--gcc/config/ia64/hpux.h9
-rw-r--r--gcc/config/ia64/linux.h5
-rw-r--r--gcc/config/ia64/vms.h3
-rw-r--r--gcc/config/kfreebsd-gnu.h8
-rw-r--r--gcc/config/kopensolaris-gnu.h12
-rw-r--r--gcc/config/linux-android.h12
-rw-r--r--gcc/config/linux.h8
-rw-r--r--gcc/config/lm32/rtems.h13
-rw-r--r--gcc/config/lm32/uclinux-elf.h2
-rw-r--r--gcc/config/m32c/rtems.h13
-rw-r--r--gcc/config/m32r/linux.h2
-rw-r--r--gcc/config/m68k/linux.h2
-rw-r--r--gcc/config/m68k/m68kemb.h10
-rw-r--r--gcc/config/m68k/netbsd-elf.h5
-rw-r--r--gcc/config/m68k/openbsd.h5
-rw-r--r--gcc/config/m68k/rtemself.h11
-rw-r--r--gcc/config/m68k/uclinux.h13
-rw-r--r--gcc/config/microblaze/linux.h5
-rw-r--r--gcc/config/microblaze/rtems.h8
-rw-r--r--gcc/config/mips/gnu-user.h5
-rw-r--r--gcc/config/mips/linux-common.h4
-rw-r--r--gcc/config/mips/netbsd.h5
-rw-r--r--gcc/config/mips/rtems.h10
-rw-r--r--gcc/config/mips/sdemtk.h11
-rw-r--r--gcc/config/mips/vxworks.h5
-rw-r--r--gcc/config/mn10300/linux.h2
-rw-r--r--gcc/config/moxie/moxiebox.h10
-rw-r--r--gcc/config/moxie/rtems.h10
-rw-r--r--gcc/config/moxie/uclinux.h2
-rw-r--r--gcc/config/nds32/linux.h5
-rw-r--r--gcc/config/netbsd.h9
-rw-r--r--gcc/config/nios2/linux.h5
-rw-r--r--gcc/config/nios2/rtems.h10
-rw-r--r--gcc/config/openbsd.h8
-rw-r--r--gcc/config/or1k/linux.h2
-rw-r--r--gcc/config/or1k/rtems.h14
-rw-r--r--gcc/config/pa/pa-hpux.h12
-rw-r--r--gcc/config/pa/pa-hpux10.h12
-rw-r--r--gcc/config/pa/pa-hpux11.h12
-rw-r--r--gcc/config/pa/pa-linux.h8
-rw-r--r--gcc/config/pa/pa-netbsd.h8
-rw-r--r--gcc/config/pa/pa-openbsd.h8
-rw-r--r--gcc/config/pa/pa.h2
-rw-r--r--gcc/config/phoenix.h12
-rw-r--r--gcc/config/riscv/linux.h5
-rw-r--r--gcc/config/riscv/rtems.h13
-rw-r--r--gcc/config/rs6000/aix.h10
-rw-r--r--gcc/config/rs6000/aix61.h8
-rw-r--r--gcc/config/rs6000/aix71.h8
-rw-r--r--gcc/config/rs6000/aix72.h8
-rw-r--r--gcc/config/rs6000/darwin.h10
-rw-r--r--gcc/config/rs6000/eabi.h12
-rw-r--r--gcc/config/rs6000/eabisim.h12
-rw-r--r--gcc/config/rs6000/linux.h8
-rw-r--r--gcc/config/rs6000/linux64.h8
-rw-r--r--gcc/config/rs6000/lynx.h12
-rw-r--r--gcc/config/rs6000/netbsd.h8
-rw-r--r--gcc/config/rs6000/rtems.h13
-rw-r--r--gcc/config/rs6000/sysv4.h13
-rw-r--r--gcc/config/rs6000/vxworks.h7
-rw-r--r--gcc/config/s390/linux.h5
-rw-r--r--gcc/config/s390/tpf.h13
-rw-r--r--gcc/config/sh/linux.h5
-rw-r--r--gcc/config/sh/netbsd-elf.h5
-rw-r--r--gcc/config/sh/rtems.h10
-rw-r--r--gcc/config/sh/rtemself.h10
-rw-r--r--gcc/config/sh/vxworks.h5
-rw-r--r--gcc/config/sol2.h10
-rw-r--r--gcc/config/sparc/linux.h5
-rw-r--r--gcc/config/sparc/linux64.h5
-rw-r--r--gcc/config/sparc/netbsd-elf.h5
-rw-r--r--gcc/config/sparc/openbsd64.h5
-rw-r--r--gcc/config/sparc/rtemself.h13
-rw-r--r--gcc/config/sparc/vxworks.h5
-rw-r--r--gcc/config/tilegx/linux.h6
-rw-r--r--gcc/config/tilepro/linux.h6
-rw-r--r--gcc/config/v850/rtems.h10
-rw-r--r--gcc/config/vax/linux.h2
-rw-r--r--gcc/config/vax/netbsd-elf.h8
-rw-r--r--gcc/config/vax/openbsd.h5
-rw-r--r--gcc/config/vms/vms.h13
-rw-r--r--gcc/config/vxworks.h8
-rw-r--r--gcc/config/vxworksae.h9
-rw-r--r--gcc/config/xtensa/linux.h2
-rw-r--r--gcc/config/xtensa/uclinux.h13
-rw-r--r--gcc/rust/rust-lang.cc7
-rw-r--r--gcc/rust/rust-session-manager.cc15
-rw-r--r--gcc/rust/rust-target-def.h20
-rw-r--r--gcc/rust/rust-target.def89
-rw-r--r--gcc/rust/rust-target.h40
143 files changed, 1555 insertions, 33 deletions
diff --git a/gcc/config/aarch64/aarch64-freebsd.h b/gcc/config/aarch64/aarch64-freebsd.h
index 68cfc44..0463a80 100644
--- a/gcc/config/aarch64/aarch64-freebsd.h
+++ b/gcc/config/aarch64/aarch64-freebsd.h
@@ -65,6 +65,14 @@
} \
while (false)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in aarch64-freebsd.h - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ FBSD_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
/* Uninitialized common symbols in non-PIE executables, even with
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index b1d1f67..194efc1 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -1,5 +1,5 @@
/* Machine description for AArch64 architecture.
- Copyright (C) 2009-2020 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
Contributed by ARM Ltd.
This file is part of GCC.
@@ -64,6 +64,13 @@
} \
while (0)
+#define GNU_USER_TARGET_D_CRITSEC_SIZE 48
+
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#define TARGET_ASM_FILE_END aarch64_file_end_indicate_exec_stack
/* Uninitialized common symbols in non-PIE executables, even with
diff --git a/gcc/config/aarch64/aarch64-netbsd.h b/gcc/config/aarch64/aarch64-netbsd.h
index 77fb0f8..0a1c2ca 100644
--- a/gcc/config/aarch64/aarch64-netbsd.h
+++ b/gcc/config/aarch64/aarch64-netbsd.h
@@ -52,6 +52,14 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in aarch64-netbsd.h - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
diff --git a/gcc/config/aarch64/aarch64-vxworks.h b/gcc/config/aarch64/aarch64-vxworks.h
index 9e172c1..5e2954b 100644
--- a/gcc/config/aarch64/aarch64-vxworks.h
+++ b/gcc/config/aarch64/aarch64-vxworks.h
@@ -54,6 +54,14 @@ along with GCC; see the file COPYING3. If not see
VXWORKS_OS_CPP_BUILTINS (); \
} while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in aarch64-vxworks.h - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ VXWORKS_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
/* Static stack checking is supported. */
#define STACK_CHECK_STATIC_BUILTIN 1
diff --git a/gcc/config/aarch64/rtems.h b/gcc/config/aarch64/rtems.h
index 6d96be2..cd622de 100644
--- a/gcc/config/aarch64/rtems.h
+++ b/gcc/config/aarch64/rtems.h
@@ -31,3 +31,16 @@
builtin_define ("__USE_INIT_FINI__"); \
builtin_assert ("system=rtems"); \
} while (0)
+
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (aarch64) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0) \ No newline at end of file
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index 3777f18..4cbedf1 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -33,6 +33,14 @@ along with GCC; see the file COPYING3. If not see
builtin_define ("_GNU_SOURCE"); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "linux"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#undef LIB_SPEC
#define LIB_SPEC \
"%{pthread:-lpthread} \
diff --git a/gcc/config/alpha/netbsd.h b/gcc/config/alpha/netbsd.h
index b2862ce..3394ebe 100644
--- a/gcc/config/alpha/netbsd.h
+++ b/gcc/config/alpha/netbsd.h
@@ -23,6 +23,10 @@ along with GCC; see the file COPYING3. If not see
NETBSD_OS_CPP_BUILTINS_ELF(); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
/* NetBSD doesn't use the LANGUAGE* built-ins. */
#undef SUBTARGET_LANGUAGE_CPP_BUILTINS
diff --git a/gcc/config/alpha/openbsd.h b/gcc/config/alpha/openbsd.h
index ae893de..2c6d467 100644
--- a/gcc/config/alpha/openbsd.h
+++ b/gcc/config/alpha/openbsd.h
@@ -48,6 +48,11 @@ along with GCC; see the file COPYING3. If not see
OPENBSD_OS_CPP_BUILTINS_LP64(); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ OPENBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Layout of source language data types. */
/* This must agree with <machine/_types.h> */
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index ce47ebd..e2d8ae5 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -41,6 +41,9 @@ along with GCC; see the file COPYING3. If not see
builtin_define ("__IEEE_FLOAT"); \
} while (0)
+#define SUBTARGET_RUST_OS_INFO() \
+ do {} while (0)
+
#undef PCC_STATIC_STRUCT_RETURN
#define MAX_OFILE_ALIGNMENT 524288 /* 8 x 2^16 by DEC Ada Test CD40VRA */
diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h
index 0863f1c..f6ca3a1 100644
--- a/gcc/config/arc/linux.h
+++ b/gcc/config/arc/linux.h
@@ -22,21 +22,30 @@ along with GCC; see the file COPYING3. If not see
#undef DWARF2_UNWIND_INFO
#define DWARF2_UNWIND_INFO 1
-#define TARGET_OS_CPP_BUILTINS() \
- do \
- { \
- GNU_USER_TARGET_OS_CPP_BUILTINS (); \
- } \
+#define TARGET_OS_CPP_BUILTINS() \
+ do \
+ { \
+ GNU_USER_TARGET_OS_CPP_BUILTINS (); \
+ } \
while (0)
-#define GLIBC_DYNAMIC_LINKER \
+#define TARGET_RUST_OS_INFO() \
+ do \
+ { \
+ GNU_USER_TARGET_RUST_OS_INFO (); \
+ /*TODO: does this properly register 'linux' as 'target_os'?*/ \
+ } \
+ while (0)
+
+#define GLIBC_DYNAMIC_LINKER \
"/lib/ld-linux-arc%{mbig-endian:eb}%{mcpu=arc700:700}.so.2"
-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
/* Note that the default is to link against dynamic libraries, if they are
available. Override with -static. */
#undef LINK_SPEC
-#define LINK_SPEC "%{h*} \
+#define LINK_SPEC \
+ "%{h*} \
%{static:-Bstatic} \
%{shared:-shared} \
%{symbolic:-Bsymbolic} \
@@ -49,15 +58,15 @@ along with GCC; see the file COPYING3. If not see
%{mcpu=nps400:-marclinux_nps; :-marclinux}"
#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
+#define STARTFILE_SPEC \
LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC)
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
+#define ENDFILE_SPEC \
LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
#undef LIB_SPEC
-#define LIB_SPEC \
+#define LIB_SPEC \
"%{pthread:-lpthread} \
%{shared:-lc} \
%{!shared:%{profile:-lc_p}%{!profile:-lc}}"
@@ -75,14 +84,15 @@ along with GCC; see the file COPYING3. If not see
/* We do not have any MULTILIB_OPTIONS specified, so there are no
MULTILIB_DEFAULTS. */
-#undef MULTILIB_DEFAULTS
+#undef MULTILIB_DEFAULTS
/* Linux toolchains use r25 as the thread pointer register. */
#undef TARGET_ARC_TP_REGNO_DEFAULT
#define TARGET_ARC_TP_REGNO_DEFAULT 25
#undef SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "\
+#define SUBTARGET_CPP_SPEC \
+ "\
%{pthread:-D_REENTRANT} \
"
@@ -103,7 +113,8 @@ along with GCC; see the file COPYING3. If not see
#endif
#undef SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "\
+#define SUBTARGET_CPP_SPEC \
+ "\
%{pthread:-D_REENTRANT} \
"
@@ -114,25 +125,25 @@ along with GCC; see the file COPYING3. If not see
/* Clear the instruction cache from `beg' to `end'. This makes an
inline system call to SYS_cacheflush. */
#undef CLEAR_INSN_CACHE
-#define CLEAR_INSN_CACHE(beg, end) \
-{ \
- register unsigned long _beg __asm ("r0") = (unsigned long) (beg); \
- register unsigned long _end __asm ("r1") = (unsigned long) (end); \
- register unsigned long _xtr __asm ("r2") = 0; \
- register unsigned long _scno __asm ("r8") = 244; \
- __asm __volatile ("trap_s 0 ; sys_cache_sync" \
- : "=r" (_beg) \
- : "0" (_beg), "r" (_end), "r" (_xtr), "r" (_scno)); \
-}
+#define CLEAR_INSN_CACHE(beg, end) \
+ { \
+ register unsigned long _beg __asm("r0") = (unsigned long) (beg); \
+ register unsigned long _end __asm("r1") = (unsigned long) (end); \
+ register unsigned long _xtr __asm("r2") = 0; \
+ register unsigned long _scno __asm("r8") = 244; \
+ __asm __volatile("trap_s 0 ; sys_cache_sync" \
+ : "=r"(_beg) \
+ : "0"(_beg), "r"(_end), "r"(_xtr), "r"(_scno)); \
+ }
/* Emit rtl for profiling. Output assembler code to FILE
to call "_mcount" for profiling a function entry. */
-#define PROFILE_HOOK(LABEL) \
- { \
- rtx fun, rt; \
- rt = get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); \
- fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); \
- emit_library_call (fun, LCT_NORMAL, VOIDmode, rt, Pmode); \
+#define PROFILE_HOOK(LABEL) \
+ { \
+ rtx fun, rt; \
+ rt = get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); \
+ fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); \
+ emit_library_call (fun, LCT_NORMAL, VOIDmode, rt, Pmode); \
}
/* Enter/Leave ops are default off for linux targets. */
diff --git a/gcc/config/arm/bpabi.h b/gcc/config/arm/bpabi.h
index eddb9b2..5e14d91 100644
--- a/gcc/config/arm/bpabi.h
+++ b/gcc/config/arm/bpabi.h
@@ -104,6 +104,17 @@
#define TARGET_OS_CPP_BUILTINS() \
TARGET_BPABI_CPP_BUILTINS()
+#define BPABI_TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: is this even an OS? What should go here?*/ \
+ } while (0)
+
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in bpabi.h - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ BPABI_TARGET_RUST_OS_INFO()
+
/* The BPABI specifies the use of .{init,fini}_array. Therefore, we
do not want GCC to put anything into the .{init,fini} sections. */
#undef INIT_SECTION_ASM_OP
diff --git a/gcc/config/arm/freebsd.h b/gcc/config/arm/freebsd.h
index 7f9eff5..9ceb214 100644
--- a/gcc/config/arm/freebsd.h
+++ b/gcc/config/arm/freebsd.h
@@ -83,6 +83,15 @@
} \
while (false)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in freebsd.h (arm) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ FBSD_TARGET_RUST_OS_INFO (); \
+ BPABI_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
/* We default to a soft-float ABI so that binaries can run on all
target hardware. */
#undef TARGET_DEFAULT_FLOAT_ABI
diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index 5bdcfa0..ddbec1d 100644
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -33,6 +33,14 @@
#define EXTRA_TARGET_D_OS_VERSIONS() \
ANDROID_TARGET_D_OS_VERSIONS();
+#define EXTRA_TARGET_RUST_OS_INFO() \
+ do { \
+ BPABI_TARGET_RUST_OS_INFO(); \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ ANDROID_TARGET_RUST_OS_INFO(); \
+ /*TODO: ensure that this makes target_os 'linux' properly and stuff*/ \
+ while (0)
+
/* We default to a soft-float ABI so that binaries can run on all
target hardware. If you override this to use the hard-float ABI then
change the setting of GLIBC_DYNAMIC_LINKER_DEFAULT as well. */
diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
index 0ec3aa5..611a4bb2 100644
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -83,6 +83,11 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Call the function profiler with a given profile label. */
#undef ARM_FUNCTION_PROFILER
#define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \
diff --git a/gcc/config/arm/netbsd-eabi.h b/gcc/config/arm/netbsd-eabi.h
index a441c47..0ccd1af 100644
--- a/gcc/config/arm/netbsd-eabi.h
+++ b/gcc/config/arm/netbsd-eabi.h
@@ -64,6 +64,16 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in netbsd-eabi.h (arm) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ if (TARGET_AAPCS_BASED) \
+ BPABI_TARGET_RUST_OS_INFO(); \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
diff --git a/gcc/config/arm/netbsd-elf.h b/gcc/config/arm/netbsd-elf.h
index 6851fb2..3ac8bb9 100644
--- a/gcc/config/arm/netbsd-elf.h
+++ b/gcc/config/arm/netbsd-elf.h
@@ -51,6 +51,14 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in netbsd-elf.h (arm) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
diff --git a/gcc/config/arm/rtems.h b/gcc/config/arm/rtems.h
index c955d1f..005db1d 100644
--- a/gcc/config/arm/rtems.h
+++ b/gcc/config/arm/rtems.h
@@ -33,4 +33,18 @@
TARGET_BPABI_CPP_BUILTINS(); \
} while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (arm) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family - TODO*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ BPABI_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#define ARM_DEFAULT_SHORT_ENUMS false
diff --git a/gcc/config/arm/symbian.h b/gcc/config/arm/symbian.h
index ebc7f10..0edb980 100644
--- a/gcc/config/arm/symbian.h
+++ b/gcc/config/arm/symbian.h
@@ -78,6 +78,21 @@
} \
while (false)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in symbian.h (arm) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for symbian, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_vendor - TODO*/ \
+ /*some triple examples i've seen are "arm-nokia-symbian-eabi" and possibly "arm-none-symbian-elf"*/ \
+ builtin_rust_info ("target_family", ""); \
+ builtin_rust_info ("target_os", "symbian"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ BPABI_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* On SymbianOS, these sections are not writable, so we use "a",
rather than "aw", for the section attributes. */
#undef ARM_EABI_CTORS_SECTION_OP
diff --git a/gcc/config/arm/uclinux-eabi.h b/gcc/config/arm/uclinux-eabi.h
index d870831..0026c5d 100644
--- a/gcc/config/arm/uclinux-eabi.h
+++ b/gcc/config/arm/uclinux-eabi.h
@@ -46,6 +46,19 @@
} \
while (false)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in uclinux-eabi.h (arm) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ BPABI_TARGET_RUST_OS_INFO(); \
+ /*note: as far as I know, rustc does not distinguish between uclinux and regular linux kernels*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "linux"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#undef SUBTARGET_EXTRA_LINK_SPEC
#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux_eabi -elf2flt" \
" --pic-veneer --target2=abs"
diff --git a/gcc/config/arm/uclinux-elf.h b/gcc/config/arm/uclinux-elf.h
index 1b42aea..bb1a553 100644
--- a/gcc/config/arm/uclinux-elf.h
+++ b/gcc/config/arm/uclinux-elf.h
@@ -48,6 +48,18 @@
} \
while (false)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in uclinux-elf.h (arm) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc does not distinguish between uclinux and regular linux kernels*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "linux"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
/* The GNU C++ standard library requires that these macros be defined. */
#undef CPLUSPLUS_CPP_SPEC
#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
diff --git a/gcc/config/arm/vxworks.h b/gcc/config/arm/vxworks.h
index 487ec0f..877e9c6 100644
--- a/gcc/config/arm/vxworks.h
+++ b/gcc/config/arm/vxworks.h
@@ -75,6 +75,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
MAYBE_TARGET_BPABI_CPP_BUILTINS (); \
} while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in vxworks.h (arm) - c++ undefines it and redefines it."
+#endif
+#ifdef BPABI_TARGET_RUST_OS_INFO
+# define MAYBE_BPABI_TARGET_RUST_OS_INFO BPABI_TARGET_RUST_OS_INFO
+#else
+# define MAYBE_BPABI_TARGET_RUST_OS_INFO()
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ VXWORKS_TARGET_RUST_OS_INFO (); \
+ MAYBE_BPABI_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#undef SUBTARGET_OVERRIDE_OPTIONS
#define SUBTARGET_OVERRIDE_OPTIONS VXWORKS_OVERRIDE_OPTIONS
diff --git a/gcc/config/bfin/linux.h b/gcc/config/bfin/linux.h
index 9c882a7..7a7a0ff 100644
--- a/gcc/config/bfin/linux.h
+++ b/gcc/config/bfin/linux.h
@@ -28,6 +28,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in linux.h (bfin) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
"%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} crtreloc.o%s \
diff --git a/gcc/config/bfin/rtems.h b/gcc/config/bfin/rtems.h
index 8bdd8e0..0390904 100644
--- a/gcc/config/bfin/rtems.h
+++ b/gcc/config/bfin/rtems.h
@@ -31,3 +31,13 @@
builtin_assert ("system=rtems"); \
} \
while (0)
+
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0) \ No newline at end of file
diff --git a/gcc/config/bfin/uclinux.h b/gcc/config/bfin/uclinux.h
index d4e4f30..02a74c6 100644
--- a/gcc/config/bfin/uclinux.h
+++ b/gcc/config/bfin/uclinux.h
@@ -27,6 +27,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#undef LINK_GCC_C_SEQUENCE_SPEC
#define LINK_GCC_C_SEQUENCE_SPEC "\
%{mfast-fp:-lbffastfp} %G %{!nolibc:%L} %{mfast-fp:-lbffastfp} %G \
diff --git a/gcc/config/c6x/uclinux-elf.h b/gcc/config/c6x/uclinux-elf.h
index bd87e4c..8e22321 100644
--- a/gcc/config/c6x/uclinux-elf.h
+++ b/gcc/config/c6x/uclinux-elf.h
@@ -32,6 +32,18 @@
} \
while (false)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in uclinux-elf.h (c6x) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc does not distinguish between uclinux and regular linux kernels*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "linux"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
"%{!shared:crt1%O%s} crti%O%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
diff --git a/gcc/config/csky/csky-linux-elf.h b/gcc/config/csky/csky-linux-elf.h
index cf587ae..26ff944 100644
--- a/gcc/config/csky/csky-linux-elf.h
+++ b/gcc/config/csky/csky-linux-elf.h
@@ -95,6 +95,11 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* In crtstuff.c to control section in where code resides.
We have to write it as asm code. */
#ifdef __PIC__
diff --git a/gcc/config/dragonfly.h b/gcc/config/dragonfly.h
index 01f6908..5463b21 100644
--- a/gcc/config/dragonfly.h
+++ b/gcc/config/dragonfly.h
@@ -35,6 +35,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in dragonflybsd.h - c++ undefines it and redefines it."
+/* TODO: ensure that this works correctly and the undef and redef reason is known */
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "dragonfly"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC \
"%(cpp_cpu) %(cpp_arch) %{posix:-D_POSIX_SOURCE}"
diff --git a/gcc/config/epiphany/rtems.h b/gcc/config/epiphany/rtems.h
index b317de1..17d1702 100644
--- a/gcc/config/epiphany/rtems.h
+++ b/gcc/config/epiphany/rtems.h
@@ -26,3 +26,16 @@
builtin_define ("__USE_INIT_FINI__"); \
builtin_assert ("system=rtems"); \
} while (0)
+
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (epiphany) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family - TODO*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/freebsd-spec.h b/gcc/config/freebsd-spec.h
index 6003647..1d00f13 100644
--- a/gcc/config/freebsd-spec.h
+++ b/gcc/config/freebsd-spec.h
@@ -49,6 +49,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Define the default FreeBSD-specific per-CPU hook code. */
#define FBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
+#define FBSD_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "freebsd"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ /*TODO: is default per-CPU hook code required here?*/ \
+ } while (0)
+
/* Provide a CPP_SPEC appropriate for FreeBSD. We just deal with the GCC
option `-posix', and PIC issues. */
diff --git a/gcc/config/freebsd.h b/gcc/config/freebsd.h
index 4b5140b..2fb9c7a 100644
--- a/gcc/config/freebsd.h
+++ b/gcc/config/freebsd.h
@@ -32,6 +32,11 @@ along with GCC; see the file COPYING3. If not see
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() FBSD_TARGET_OS_CPP_BUILTINS()
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in freebsd.h - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() FBSD_TARGET_RUST_OS_INFO()
+
#undef CPP_SPEC
#define CPP_SPEC FBSD_CPP_SPEC
diff --git a/gcc/config/frv/linux.h b/gcc/config/frv/linux.h
index ce725cb..d3c4ddc 100644
--- a/gcc/config/frv/linux.h
+++ b/gcc/config/frv/linux.h
@@ -57,6 +57,14 @@
builtin_assert ("system=linux"); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "linux"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#define HAS_INIT_SECTION 1
#define INIT_SECTION_ASM_OP "\t.section .init,\"ax\""
#define FINI_SECTION_ASM_OP "\t.section .fini,\"ax\""
diff --git a/gcc/config/fuchsia.h b/gcc/config/fuchsia.h
index f7a0f9e..a511f22 100644
--- a/gcc/config/fuchsia.h
+++ b/gcc/config/fuchsia.h
@@ -66,3 +66,19 @@ along with GCC; see the file COPYING3. If not see
} \
while (false)
+#ifndef EXTRA_TARGET_RUST_OS_INFO
+#define EXTRA_TARGET_RUST_OS_INFO()
+#endif
+
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in fuchsia.h - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ /*NOTE: target_family is subject to change if rustc decides to change it to non-unix*/ \
+ builtin_rust_info ("target_os", "fuchsia"); \
+ builtin_rust_info ("target_vendor", ""); \
+ builtin_rust_info ("target_env", ""); \
+ EXTRA_TARGET_RUST_OS_INFO(); \
+ } while (0)
diff --git a/gcc/config/gnu.h b/gcc/config/gnu.h
index d6d5e98..ba19edf 100644
--- a/gcc/config/gnu.h
+++ b/gcc/config/gnu.h
@@ -37,3 +37,12 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>.
builtin_version ("Hurd"); \
builtin_version ("CRuntime_Glibc"); \
} while (0)
+
+#define GNU_USER_TARGET_RUST_OS_INFO() \
+ do { /*is this correct? or should os be "hurd"?*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "gnu"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ /* TODO: is target_env required?*/ \
+ } while (0) \ No newline at end of file
diff --git a/gcc/config/h8300/linux.h b/gcc/config/h8300/linux.h
index 9621c47..62fdccc 100644
--- a/gcc/config/h8300/linux.h
+++ b/gcc/config/h8300/linux.h
@@ -29,6 +29,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef LINK_SPEC
#define LINK_SPEC "%{mh:-mh8300helf_linux} %{ms:-m h8300self_linux} %{msx:-m h8300sxelf_linux}"
diff --git a/gcc/config/i386/crtdll.h b/gcc/config/i386/crtdll.h
index 9c441c0..2441e0c 100644
--- a/gcc/config/i386/crtdll.h
+++ b/gcc/config/i386/crtdll.h
@@ -31,6 +31,18 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef EXTRA_TARGET_RUST_OS_INFO
+# error "EXTRA_TARGET_RUST_OS_INFO already defined in crtdll.h (i386) - c++ undefines it and redefines it."
+#endif
+#define EXTRA_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "windows"); \
+ builtin_rust_info ("target_os", "windows"); \
+ builtin_rust_info ("target_vendor", "pc"); \
+ /*TODO: is this the right target_env? it says gnu tools up there, but env may change.*/ \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#undef LIBGCC_SPEC
#define LIBGCC_SPEC \
"%{mthreads:-lmingwthrd} -lmingw32 -lgcc -lcoldname -libmingwex -lcrtdll"
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 1b1ea7d..8ff8cde 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -160,6 +160,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ EXTRA_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
/* Get tree.c to declare a target-specific specialization of
merge_decl_attributes. */
#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h
index 73737f4..d784ca1 100644
--- a/gcc/config/i386/cygwin.h
+++ b/gcc/config/i386/cygwin.h
@@ -29,6 +29,16 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define EXTRA_TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: derived from llvm triple - rustc has no support for cygwin, but follows llvm triple*/ \
+ /*target_family is defined as unix due to posix-compliance, but this is subject to change*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "windows"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "cygnus"); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
%{!ansi:-Dunix} \
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index fec934a..e8f6fd5 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -81,6 +81,16 @@ along with GCC; see the file COPYING3. If not see
darwin_cpp_builtins (pfile); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ /*TODO: rust actually has "macos", "ios", and "tvos" for darwin targets, but gcc seems to have no*/ \
+ /*current support for them, so assuming that target_os is always macos for now*/ \
+ builtin_rust_info ("target_os", "macos"); \
+ builtin_rust_info ("target_vendor", "apple"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#undef PTRDIFF_TYPE
#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
diff --git a/gcc/config/i386/djgpp.h b/gcc/config/i386/djgpp.h
index 62bfd3a..a5265d7 100644
--- a/gcc/config/i386/djgpp.h
+++ b/gcc/config/i386/djgpp.h
@@ -57,6 +57,15 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*rustc has no support for this, so values are taken from rusty-dos' djgpp github issue guesses*/ \
+ builtin_rust_info ("target_family", "windows"); \
+ builtin_rust_info ("target_os", "msdos"); \
+ builtin_rust_info ("target_vendor", "pc"); \
+ builtin_rust_info ("target_env", "djgpp"); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE}"
diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h
index 10392e6..60801cc 100644
--- a/gcc/config/i386/gnu-user-common.h
+++ b/gcc/config/i386/gnu-user-common.h
@@ -36,6 +36,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
diff --git a/gcc/config/i386/i386-rust.c b/gcc/config/i386/i386-rust.c
new file mode 100644
index 0000000..44ca0c9
--- /dev/null
+++ b/gcc/config/i386/i386-rust.c
@@ -0,0 +1,236 @@
+/* Subroutines for the Rust front end on the x86 architecture.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rust/rust-target.h"
+#include "rust/rust-target-def.h"
+
+// FIXME: remove: this is only here to make intellisense happy
+#include "i386.h"
+
+// HACK: allows conversion of (presumably) numeric values to string
+#ifndef STR_HELPER_RUST
+ #define STR_HELPER_RUST(x) #x
+#else
+ #error "STR_HELPER_RUST already defined!!!"
+#endif
+
+#ifndef STRINGIFY_RUST
+ #define STRINGIFY_RUST(x) STR_HELPER_RUST(x)
+#else
+ #error "STRINGIFY_RUST already defined!!!"
+#endif
+
+/* Implement TARGET_RUST_CPU_INFO for x86 targets. */
+
+void
+ix86_rust_target_cpu_info (void)
+{
+ if (TARGET_64BIT) {
+ rust_add_target_info("target_arch", "x86_64");
+
+ // TODO: should these go here or is there a platform-neutral way of getting them (since they aren't defined in i386-c.c or i386-d.c)?
+ rust_add_target_info("target_pointer_width", STRINGIFY_RUST(POINTER_SIZE));
+ rust_add_target_info("target_endian", BYTES_BIG_ENDIAN ? "big" : "little");
+
+ if (TARGET_X32) {
+ // this means it uses 32-bit pointers with 64-bit, basically (ILP32)
+ rust_add_target_info("target_pointer_width", "32");
+ // TODO: may also change x86_64-...-linux-gnu to x86_64-...-linux-gnux32
+
+ // is this better than just putting in pointer width outside of if statement?
+
+ /* TODO: compared to base linux, may also need to change max_atomic_width to 64, add "-mx32"
+ * to pre-link args, make stack_probes true, make has_elf_tls false, make needs_plt true.
+ * Also, still target_endian is "little", target_c_int_width is "32", maybe steal data layout
+ * later from rustc spec, target_os is "linux", target_env is "gnu", target_vendor is "unknown"
+ * There is no rustc support for non-gnu/linux targets with ILP32. */
+ }
+ } else {
+ rust_add_target_info("target_arch", "x86");
+ }
+
+ // maybe more stuff I don't understand if evidenced by ix86_target_macros in i386-c.c
+
+ // note: options that don't seem to have a target feature in rust are commented out
+
+ if (isa_flag2 & OPTION_MASK_ISA_WBNOINVD)
+ //def_or_undef (parse_in, "__WBNOINVD__");
+ if (isa_flag2 & OPTION_MASK_ISA_AVX512VP2INTERSECT)
+ //def_or_undef (parse_in, "__AVX512VP2INTERSECT__");
+ if (isa_flag & OPTION_MASK_ISA_MMX)
+ rust_add_target_info("target_feature", "mmx");
+ if (isa_flag & OPTION_MASK_ISA_3DNOW)
+ //def_or_undef (parse_in, "__3dNOW__");
+ if (isa_flag & OPTION_MASK_ISA_3DNOW_A)
+ //def_or_undef (parse_in, "__3dNOW_A__");
+ if (isa_flag & OPTION_MASK_ISA_SSE)
+ rust_add_target_info("target_feature", "sse");
+ if (isa_flag & OPTION_MASK_ISA_SSE2)
+ rust_add_target_info("target_feature", "sse2");
+ if (isa_flag & OPTION_MASK_ISA_SSE3)
+ rust_add_target_info("target_feature", "sse3");
+ if (isa_flag & OPTION_MASK_ISA_SSSE3)
+ rust_add_target_info("target_feature", "ssse3");
+ if (isa_flag & OPTION_MASK_ISA_SSE4_1)
+ rust_add_target_info("target_feature", "sse4.1");
+ if (isa_flag & OPTION_MASK_ISA_SSE4_2)
+ rust_add_target_info("target_feature", "sse4.2");
+ if (isa_flag & OPTION_MASK_ISA_AES)
+ rust_add_target_info("target_feature", "aes");
+ if (isa_flag & OPTION_MASK_ISA_SHA)
+ rust_add_target_info("target_feature", "sha");
+ if (isa_flag & OPTION_MASK_ISA_PCLMUL)
+ //def_or_undef (parse_in, "__PCLMUL__");
+ if (isa_flag & OPTION_MASK_ISA_AVX)
+ rust_add_target_info("target_feature", "avx");
+ if (isa_flag & OPTION_MASK_ISA_AVX2)
+ rust_add_target_info("target_feature", "avx2");
+ if (isa_flag & OPTION_MASK_ISA_AVX512F)
+ //def_or_undef (parse_in, "__AVX512F__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512ER)
+ //def_or_undef (parse_in, "__AVX512ER__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512CD)
+ //def_or_undef (parse_in, "__AVX512CD__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512PF)
+ //def_or_undef (parse_in, "__AVX512PF__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512DQ)
+ //def_or_undef (parse_in, "__AVX512DQ__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512BW)
+ //def_or_undef (parse_in, "__AVX512BW__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512VL)
+ //def_or_undef (parse_in, "__AVX512VL__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512VBMI)
+ //def_or_undef (parse_in, "__AVX512VBMI__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512IFMA)
+ //def_or_undef (parse_in, "__AVX512IFMA__");
+ if (isa_flag2 & OPTION_MASK_ISA_AVX5124VNNIW)
+ //def_or_undef (parse_in, "__AVX5124VNNIW__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512VBMI2)
+ //def_or_undef (parse_in, "__AVX512VBMI2__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512VNNI)
+ //def_or_undef (parse_in, "__AVX512VNNI__");
+ if (isa_flag2 & OPTION_MASK_ISA_PCONFIG)
+ //def_or_undef (parse_in, "__PCONFIG__");
+ if (isa_flag2 & OPTION_MASK_ISA_SGX)
+ //def_or_undef (parse_in, "__SGX__");
+ if (isa_flag2 & OPTION_MASK_ISA_AVX5124FMAPS)
+ //def_or_undef (parse_in, "__AVX5124FMAPS__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512BITALG)
+ //def_or_undef (parse_in, "__AVX512BITALG__");
+ if (isa_flag & OPTION_MASK_ISA_AVX512VPOPCNTDQ)
+ //def_or_undef (parse_in, "__AVX512VPOPCNTDQ__");
+ if (isa_flag & OPTION_MASK_ISA_FMA)
+ rust_add_target_info("target_feature", "fma");
+ if (isa_flag & OPTION_MASK_ISA_RTM)
+ //def_or_undef (parse_in, "__RTM__");
+ if (isa_flag & OPTION_MASK_ISA_SSE4A)
+ //def_or_undef (parse_in, "__SSE4A__");
+ if (isa_flag & OPTION_MASK_ISA_FMA4)
+ //def_or_undef (parse_in, "__FMA4__");
+ if (isa_flag & OPTION_MASK_ISA_XOP)
+ //def_or_undef (parse_in, "__XOP__");
+ if (isa_flag & OPTION_MASK_ISA_LWP)
+ //def_or_undef (parse_in, "__LWP__");
+ if (isa_flag & OPTION_MASK_ISA_ABM)
+ //def_or_undef (parse_in, "__ABM__");
+ if (isa_flag & OPTION_MASK_ISA_BMI)
+ rust_add_target_info("target_feature", "bmi1");
+ if (isa_flag & OPTION_MASK_ISA_BMI2)
+ rust_add_target_info("target_feature", "bmi2");
+ if (isa_flag & OPTION_MASK_ISA_LZCNT)
+ rust_add_target_info("target_feature", "lzcnt");
+ if (isa_flag & OPTION_MASK_ISA_TBM)
+ //def_or_undef (parse_in, "__TBM__");
+ if (isa_flag & OPTION_MASK_ISA_POPCNT)
+ rust_add_target_info("target_feature", "popcnt");
+ if (isa_flag & OPTION_MASK_ISA_FSGSBASE)
+ //def_or_undef (parse_in, "__FSGSBASE__");
+ if (isa_flag & OPTION_MASK_ISA_RDRND)
+ rust_add_target_info("target_feature", "rdrand");
+ if (isa_flag & OPTION_MASK_ISA_F16C)
+ //def_or_undef (parse_in, "__F16C__");
+ if (isa_flag & OPTION_MASK_ISA_RDSEED)
+ rust_add_target_info("target_feature", "rdseed");
+ if (isa_flag & OPTION_MASK_ISA_PRFCHW)
+ //def_or_undef (parse_in, "__PRFCHW__");
+ if (isa_flag & OPTION_MASK_ISA_ADX)
+ //def_or_undef (parse_in, "__ADX__");
+ if (isa_flag & OPTION_MASK_ISA_FXSR)
+ rust_add_target_info("target_feature", "fxsr");
+ if (isa_flag & OPTION_MASK_ISA_XSAVE)
+ rust_add_target_info("target_feature", "xsave");
+ if (isa_flag & OPTION_MASK_ISA_XSAVEOPT)
+ rust_add_target_info("target_feature", "xsaveopt");
+ if (isa_flag & OPTION_MASK_ISA_PREFETCHWT1)
+ //def_or_undef (parse_in, "__PREFETCHWT1__");
+ if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE))
+ //def_or_undef (parse_in, "__SSE_MATH__");
+ if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE2))
+ //def_or_undef (parse_in, "__SSE2_MATH__");
+ if (isa_flag & OPTION_MASK_ISA_CLFLUSHOPT)
+ //def_or_undef (parse_in, "__CLFLUSHOPT__");
+ if (isa_flag2 & OPTION_MASK_ISA_CLZERO)
+ //def_or_undef (parse_in, "__CLZERO__");
+ if (isa_flag & OPTION_MASK_ISA_XSAVEC)
+ rust_add_target_info("target_feature", "xsavec");
+ if (isa_flag & OPTION_MASK_ISA_XSAVES)
+ rust_add_target_info("target_feature", "xsaves");
+ if (isa_flag & OPTION_MASK_ISA_CLWB)
+ //def_or_undef (parse_in, "__CLWB__");
+ if (isa_flag2 & OPTION_MASK_ISA_MWAITX)
+ //def_or_undef (parse_in, "__MWAITX__");
+ if (isa_flag & OPTION_MASK_ISA_PKU)
+ //def_or_undef (parse_in, "__PKU__");
+ if (isa_flag2 & OPTION_MASK_ISA_RDPID)
+ //def_or_undef (parse_in, "__RDPID__");
+ if (isa_flag & OPTION_MASK_ISA_GFNI)
+ //def_or_undef (parse_in, "__GFNI__");
+ if ((isa_flag & OPTION_MASK_ISA_SHSTK))
+ //def_or_undef (parse_in, "__SHSTK__");
+ if (isa_flag2 & OPTION_MASK_ISA_VAES)
+ //def_or_undef (parse_in, "__VAES__");
+ if (isa_flag & OPTION_MASK_ISA_VPCLMULQDQ)
+ rust_add_target_info("target_feature", "pclmulqdq");
+ if (isa_flag & OPTION_MASK_ISA_MOVDIRI)
+ //def_or_undef (parse_in, "__MOVDIRI__");
+ if (isa_flag2 & OPTION_MASK_ISA_MOVDIR64B)
+ //def_or_undef (parse_in, "__MOVDIR64B__");
+ if (isa_flag2 & OPTION_MASK_ISA_WAITPKG)
+ //def_or_undef (parse_in, "__WAITPKG__");
+ if (isa_flag2 & OPTION_MASK_ISA_CLDEMOTE)
+ //def_or_undef (parse_in, "__CLDEMOTE__");
+ if (isa_flag2 & OPTION_MASK_ISA_PTWRITE)
+ //def_or_undef (parse_in, "__PTWRITE__");
+ if (isa_flag2 & OPTION_MASK_ISA_AVX512BF16)
+ //def_or_undef (parse_in, "__AVX512BF16__");
+ if (TARGET_MMX_WITH_SSE)
+ //def_or_undef (parse_in, "__MMX_WITH_SSE__");
+ if (isa_flag2 & OPTION_MASK_ISA_ENQCMD)
+ //def_or_undef (parse_in, "__ENQCMD__");
+ if (TARGET_IAMCU)
+ {
+ //def_or_undef (parse_in, "__iamcu");
+ //def_or_undef (parse_in, "__iamcu__");
+ }
+}
+
+#undef STR_HELPER_RUST
+#undef STRINGIFY_RUST \ No newline at end of file
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index b8ae16e..494f136 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -801,6 +801,9 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
/* Target CPU versions for D. */
#define TARGET_D_CPU_VERSIONS ix86_d_target_versions
+/* Target CPU info for Rust. */
+#define TARGET_RUST_CPU_INFO ix86_rust_target_cpu_info
+
#ifndef CC1_SPEC
#define CC1_SPEC "%(cc1_cpu) "
#endif
diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index 982390d..96dc632 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -30,6 +30,17 @@ along with GCC; see the file COPYING3. If not see
#define EXTRA_TARGET_D_OS_VERSIONS() \
ANDROID_TARGET_D_OS_VERSIONS();
+#define EXTRA_TARGET_RUST_OS_INFO() \
+ ANDROID_TARGET_RUST_OS_INFO();
+// TODO: decide on whether following c frontend style or d one - leaning towards c
+
+#undef TARGET_RUST_OS_INFO
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ ANDROID_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CC1_SPEC
#define CC1_SPEC \
LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
diff --git a/gcc/config/i386/lynx.h b/gcc/config/i386/lynx.h
index 9c6adb5..92eae0a 100644
--- a/gcc/config/i386/lynx.h
+++ b/gcc/config/i386/lynx.h
@@ -25,6 +25,15 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: not supported by rustc and so subject to change - based on llvm triple*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "lynxos"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* The svr4 ABI for the i386 says that records and unions are returned
in memory. */
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
index 321c30e..b6e8a57 100644
--- a/gcc/config/i386/mingw32.h
+++ b/gcc/config/i386/mingw32.h
@@ -53,6 +53,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define EXTRA_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "windows"); \
+ builtin_rust_info ("target_os", "windows"); \
+ builtin_rust_info ("target_vendor", "pc"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#ifndef TARGET_USE_PTHREAD_BY_DEFAULT
#define SPEC_PTHREAD1 "pthread"
#define SPEC_PTHREAD2 "!no-pthread"
diff --git a/gcc/config/i386/netbsd-elf.h b/gcc/config/i386/netbsd-elf.h
index d7dfe4c..1a8d545 100644
--- a/gcc/config/i386/netbsd-elf.h
+++ b/gcc/config/i386/netbsd-elf.h
@@ -26,6 +26,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Extra specs needed for NetBSD/i386 ELF. */
diff --git a/gcc/config/i386/netbsd64.h b/gcc/config/i386/netbsd64.h
index a14a835..86dc79f 100644
--- a/gcc/config/i386/netbsd64.h
+++ b/gcc/config/i386/netbsd64.h
@@ -26,6 +26,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Extra specs needed for NetBSD/x86-64 ELF. */
diff --git a/gcc/config/i386/nto.h b/gcc/config/i386/nto.h
index c09c2b1..2dbe652 100644
--- a/gcc/config/i386/nto.h
+++ b/gcc/config/i386/nto.h
@@ -36,6 +36,18 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in nto.h (i386) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: not supported by rustc and so subject to change - based on triple found online*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "nto"); \
+ builtin_rust_info ("target_vendor", "pc"); \
+ builtin_rust_info ("target_env", "qnx"); \
+ } while (0)
+
#undef THREAD_MODEL_SPEC
#define THREAD_MODEL_SPEC "posix"
diff --git a/gcc/config/i386/openbsdelf.h b/gcc/config/i386/openbsdelf.h
index 7771e4c..5c135b4 100644
--- a/gcc/config/i386/openbsdelf.h
+++ b/gcc/config/i386/openbsdelf.h
@@ -25,6 +25,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ OPENBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(n) \
(TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
diff --git a/gcc/config/i386/rdos.h b/gcc/config/i386/rdos.h
index 74af3ec..b87a05b6 100644
--- a/gcc/config/i386/rdos.h
+++ b/gcc/config/i386/rdos.h
@@ -37,3 +37,14 @@ along with GCC; see the file COPYING3. If not see
builtin_assert ("system=rdos"); \
} \
while (0)
+
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: not supported by rustc and so subject to change - based on triple found online*/ \
+ /*this seems to not refer to the 70s Data General RDOS, but one partly compatible with win32*/ \
+ /*as such, target_family could be windows*/ \
+ builtin_rust_info ("target_family", ""); \
+ builtin_rust_info ("target_os", "rdos"); \
+ builtin_rust_info ("target_vendor", "pc"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/i386/rtemself.h b/gcc/config/i386/rtemself.h
index d3cc8ad..c81dbbf 100644
--- a/gcc/config/i386/rtemself.h
+++ b/gcc/config/i386/rtemself.h
@@ -33,3 +33,13 @@
builtin_assert ("system=rtems"); \
} \
while (0)
+
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386
index e5fb061..3cc012f 100644
--- a/gcc/config/i386/t-i386
+++ b/gcc/config/i386/t-i386
@@ -45,6 +45,10 @@ i386-d.o: $(srcdir)/config/i386/i386-d.c
$(COMPILE) $<
$(POSTCOMPILE)
+i386-rust.o: $(srcdir)/config/i386/i386-rust.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
i386-options.o: $(srcdir)/config/i386/i386-options.c
$(COMPILE) $<
$(POSTCOMPILE)
diff --git a/gcc/config/i386/vxworks.h b/gcc/config/i386/vxworks.h
index 891b4ff..275fd69 100644
--- a/gcc/config/i386/vxworks.h
+++ b/gcc/config/i386/vxworks.h
@@ -113,6 +113,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ VXWORKS_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC VXWORKS_ADDITIONAL_CPP_SPEC
#undef CC1_SPEC
diff --git a/gcc/config/ia64/hpux.h b/gcc/config/ia64/hpux.h
index e19797c..44e3cc2 100644
--- a/gcc/config/ia64/hpux.h
+++ b/gcc/config/ia64/hpux.h
@@ -52,6 +52,15 @@ do { \
builtin_define("_ILP32"); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: rustc has no supported for hp-ux, so this is subject to change (and guessed)*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "hpux"); \
+ builtin_rust_info ("target_vendor", "hp"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC \
"%{mt|pthread:-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L}"
diff --git a/gcc/config/ia64/linux.h b/gcc/config/ia64/linux.h
index ee38e21..282066d 100644
--- a/gcc/config/ia64/linux.h
+++ b/gcc/config/ia64/linux.h
@@ -34,6 +34,11 @@ do { \
builtin_define("_LONGLONG"); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in. */
#undef STARTFILE_SPEC
#ifdef HAVE_LD_PIE
diff --git a/gcc/config/ia64/vms.h b/gcc/config/ia64/vms.h
index e14349a..9da1a87 100644
--- a/gcc/config/ia64/vms.h
+++ b/gcc/config/ia64/vms.h
@@ -26,6 +26,9 @@ along with GCC; see the file COPYING3. If not see
builtin_define ("__IEEE_FLOAT"); \
} while (0)
+#define SUBTARGET_RUST_OS_INFO() \
+ do {} while (0)
+
/* Need .debug_line info generated from gcc and gas. */
#undef TARGET_DEFAULT
#define TARGET_DEFAULT (MASK_DWARF2_ASM | MASK_GNU_AS)
diff --git a/gcc/config/kfreebsd-gnu.h b/gcc/config/kfreebsd-gnu.h
index 6ba43a9..2d99475 100644
--- a/gcc/config/kfreebsd-gnu.h
+++ b/gcc/config/kfreebsd-gnu.h
@@ -35,6 +35,14 @@ along with GCC; see the file COPYING3. If not see
builtin_version ("CRuntime_Glibc"); \
} while (0)
+#define GNU_USER_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "kfreebsd"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
#define GNU_USER_DYNAMIC_LINKER32 GLIBC_DYNAMIC_LINKER32
#define GNU_USER_DYNAMIC_LINKER64 GLIBC_DYNAMIC_LINKER64
diff --git a/gcc/config/kopensolaris-gnu.h b/gcc/config/kopensolaris-gnu.h
index 36b84c5..9045f66 100644
--- a/gcc/config/kopensolaris-gnu.h
+++ b/gcc/config/kopensolaris-gnu.h
@@ -36,5 +36,17 @@ along with GCC; see the file COPYING3. If not see
builtin_version ("CRuntime_Glibc"); \
} while (0)
+#ifdef GNU_USER_TARGET_RUST_OS_INFO
+# error # error "TARGET_RUST_OS_INFO already defined in kopensolaris-gnu.h - c++ undefines it and redefines it."
+#endif
+#define GNU_USER_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "kopensolaris"); \
+ /*the target_os is maybe not right but i can't find any better atm*/ \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
#undef GNU_USER_DYNAMIC_LINKER
#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
diff --git a/gcc/config/linux-android.h b/gcc/config/linux-android.h
index 0bd6184..9bff9d8 100644
--- a/gcc/config/linux-android.h
+++ b/gcc/config/linux-android.h
@@ -31,6 +31,18 @@
builtin_version ("Android"); \
} while (0)
+#define ANDROID_TARGET_RUST_OS_INFO() \
+ do { \
+ if (TARGET_ANDROID) { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "android"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } else { \
+ builtin_rust_info ("target_os", "linux"); \
+ } /*this else is required if I'm intepreting structure of defines correctly*/ \
+ } while (0)
+
#if ANDROID_DEFAULT
# define NOANDROID "mno-android"
#else
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index 95654bc..ae8f67b 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -66,6 +66,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
builtin_version ("CRuntime_Musl"); \
} while (0)
+#define GNU_USER_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ /*is there way of determining target_os and target_env here since could also be android?*/ \
+ /*target_vendor may not be "unknown" - FIXME ensure it is*/ \
+ } while (0)
+
/* Determine which dynamic linker to use depending on whether GLIBC or
uClibc or Bionic or musl is the default C library and whether
-muclibc or -mglibc or -mbionic or -mmusl has been passed to change
diff --git a/gcc/config/lm32/rtems.h b/gcc/config/lm32/rtems.h
index 912e988..f9964c3 100644
--- a/gcc/config/lm32/rtems.h
+++ b/gcc/config/lm32/rtems.h
@@ -33,5 +33,18 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (lm32) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family - TODO*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Use the default */
#undef LINK_GCC_C_SEQUENCE_SPEC
diff --git a/gcc/config/lm32/uclinux-elf.h b/gcc/config/lm32/uclinux-elf.h
index a459ccd..07757e0 100644
--- a/gcc/config/lm32/uclinux-elf.h
+++ b/gcc/config/lm32/uclinux-elf.h
@@ -67,6 +67,8 @@
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#define LINK_GCC_C_SEQUENCE_SPEC \
"%{static|static-pie:--start-group} %G %{!nolibc:%L} \
%{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
diff --git a/gcc/config/m32c/rtems.h b/gcc/config/m32c/rtems.h
index 5413e27..a85bf23 100644
--- a/gcc/config/m32c/rtems.h
+++ b/gcc/config/m32c/rtems.h
@@ -34,5 +34,18 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (m32c) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family - TODO*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Use the default */
#undef LINK_GCC_C_SEQUENCE_SPEC
diff --git a/gcc/config/m32r/linux.h b/gcc/config/m32r/linux.h
index f498372..ac1ac18 100644
--- a/gcc/config/m32r/linux.h
+++ b/gcc/config/m32r/linux.h
@@ -88,4 +88,6 @@
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
diff --git a/gcc/config/m68k/linux.h b/gcc/config/m68k/linux.h
index 0d18e5a..0e846d9 100644
--- a/gcc/config/m68k/linux.h
+++ b/gcc/config/m68k/linux.h
@@ -60,6 +60,8 @@ along with GCC; see the file COPYING3. If not see
/* Target OS builtins. */
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#undef CPP_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
diff --git a/gcc/config/m68k/m68kemb.h b/gcc/config/m68k/m68kemb.h
index f2c3a35..2d062db 100644
--- a/gcc/config/m68k/m68kemb.h
+++ b/gcc/config/m68k/m68kemb.h
@@ -39,6 +39,16 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: assuming that embedded means "no operating system", at least by rustc terms*/ \
+ /*basing this all on embedinomicon sample targets*/ \
+ builtin_rust_info ("target_family", ""); \
+ builtin_rust_info ("target_os", "none"); \
+ builtin_rust_info ("target_vendor", ""); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Override the default LIB_SPEC from gcc.c. We don't currently support
profiling, or libg.a. */
diff --git a/gcc/config/m68k/netbsd-elf.h b/gcc/config/m68k/netbsd-elf.h
index 616b3d4..8711802 100644
--- a/gcc/config/m68k/netbsd-elf.h
+++ b/gcc/config/m68k/netbsd-elf.h
@@ -35,6 +35,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Don't try using XFmode on the 68010. */
#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE (TARGET_68020 ? 80 : 64)
diff --git a/gcc/config/m68k/openbsd.h b/gcc/config/m68k/openbsd.h
index ffd6e8b..4993199 100644
--- a/gcc/config/m68k/openbsd.h
+++ b/gcc/config/m68k/openbsd.h
@@ -28,6 +28,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ OPENBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Define __HAVE_68881__ in preprocessor, unless -msoft-float is specified.
This will control the use of inline 68881 insns in certain macros. */
#undef CPP_SPEC
diff --git a/gcc/config/m68k/rtemself.h b/gcc/config/m68k/rtemself.h
index 26d614d..695ff50 100644
--- a/gcc/config/m68k/rtemself.h
+++ b/gcc/config/m68k/rtemself.h
@@ -36,3 +36,14 @@
builtin_assert ("system=rtems"); \
} \
while (0)
+
+#undef TARGET_RUST_OS_INFO /* This undef is actually necessary because m68kemb.h assumes embedded. */
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family - TODO*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/m68k/uclinux.h b/gcc/config/m68k/uclinux.h
index 52f92c5..47f5bb5 100644
--- a/gcc/config/m68k/uclinux.h
+++ b/gcc/config/m68k/uclinux.h
@@ -58,6 +58,19 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in uclinux.h (m68k) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc does not distinguish between uclinux and regular linux kernels*/ \
+ /*TODO: check whether defining this as GNU_USER_TARGET_RUST_OS_INFO would have different behaviour*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "linux"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
/* -msep-data is the default PIC mode on this target. */
#define DRIVER_SELF_SPECS \
"%{" FPIE_OR_FPIC_SPEC ":%{!msep-data:%{!mid-shared-library: -msep-data}}}"
diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
index 7eded69..feb7033 100644
--- a/gcc/config/microblaze/linux.h
+++ b/gcc/config/microblaze/linux.h
@@ -58,4 +58,9 @@
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in linux.h (microblaze) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
diff --git a/gcc/config/microblaze/rtems.h b/gcc/config/microblaze/rtems.h
index 1a9db25..0a494a3 100644
--- a/gcc/config/microblaze/rtems.h
+++ b/gcc/config/microblaze/rtems.h
@@ -29,6 +29,14 @@
builtin_assert( "system=rtems" ); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Redefine to include only items relevant for RTEMS */
#undef LINK_SPEC
#define LINK_SPEC "%{shared:-shared} -N -relax \
diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h
index 5d07821..d385bdc 100644
--- a/gcc/config/mips/gnu-user.h
+++ b/gcc/config/mips/gnu-user.h
@@ -38,6 +38,11 @@ along with GCC; see the file COPYING3. If not see
builtin_define ("_GNU_SOURCE"); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
diff --git a/gcc/config/mips/linux-common.h b/gcc/config/mips/linux-common.h
index 9c77e36..5b41c24 100644
--- a/gcc/config/mips/linux-common.h
+++ b/gcc/config/mips/linux-common.h
@@ -30,6 +30,10 @@ along with GCC; see the file COPYING3. If not see
#define EXTRA_TARGET_D_OS_VERSIONS() \
ANDROID_TARGET_D_OS_VERSIONS();
+#define EXTRA_TARGET_RUST_OS_INFO() \
+ ANDROID_TARGET_RUST_OS_INFO();
+/*TODO: ensure that correct target data is being set here. */
+
#undef LINK_SPEC
#define LINK_SPEC \
LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
diff --git a/gcc/config/mips/netbsd.h b/gcc/config/mips/netbsd.h
index 9c93d29..4056e2a 100644
--- a/gcc/config/mips/netbsd.h
+++ b/gcc/config/mips/netbsd.h
@@ -45,6 +45,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD.
Specifically, they define too many namespace-invasive macros. Override
them here. Note this is structured for easy comparison to the version
diff --git a/gcc/config/mips/rtems.h b/gcc/config/mips/rtems.h
index 3bbca31..84017cc 100644
--- a/gcc/config/mips/rtems.h
+++ b/gcc/config/mips/rtems.h
@@ -32,6 +32,16 @@ do { \
builtin_assert ("system=rtems"); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* No sdata.
* The RTEMS BSPs expect -G0
*/
diff --git a/gcc/config/mips/sdemtk.h b/gcc/config/mips/sdemtk.h
index 6a5a817..cd7e678 100644
--- a/gcc/config/mips/sdemtk.h
+++ b/gcc/config/mips/sdemtk.h
@@ -53,6 +53,17 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: WTF is SDE and why can't I find any info on it? is it even a real os?*/ \
+ /*note: as far as I know, rustc has no supported for sde, so this is just guessed*/ \
+ /*literally everything is subject to change because of the lack of info I can find on it*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "sde"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* For __clear_cache in libgcc2.c. */
#ifdef IN_LIBGCC2
extern void mips_sync_icache (void *beg, unsigned long len);
diff --git a/gcc/config/mips/vxworks.h b/gcc/config/mips/vxworks.h
index 762e579..484010e 100644
--- a/gcc/config/mips/vxworks.h
+++ b/gcc/config/mips/vxworks.h
@@ -58,6 +58,11 @@ VXWORKS_LINK_SPEC
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ VXWORKS_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC VXWORKS_ADDITIONAL_CPP_SPEC
diff --git a/gcc/config/mn10300/linux.h b/gcc/config/mn10300/linux.h
index a336497..a8ee7d9 100644
--- a/gcc/config/mn10300/linux.h
+++ b/gcc/config/mn10300/linux.h
@@ -24,6 +24,8 @@
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#undef CPP_SPEC
#define CPP_SPEC "%{mam33:-D__AM33__} %{!mam33:-D__AM33__=2 -D__AM33_2__} \
%{posix:-D_POSIX_SOURCE} \
diff --git a/gcc/config/moxie/moxiebox.h b/gcc/config/moxie/moxiebox.h
index 288f1cb..496e749 100644
--- a/gcc/config/moxie/moxiebox.h
+++ b/gcc/config/moxie/moxiebox.h
@@ -28,6 +28,16 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: rustc has no supported for moxiebox, so this is just guessed - values subject to change*/ \
+ /*I can find virtually no info on target triples, so target_family and target_vendor most of all*/ \
+ builtin_rust_info ("target_family", ""); \
+ builtin_rust_info ("target_os", "moxiebox"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#undef LIB_SPEC
#define LIB_SPEC \
"%{!T*:-Tmoxiebox.ld} \
diff --git a/gcc/config/moxie/rtems.h b/gcc/config/moxie/rtems.h
index a678edc..0cdadff 100644
--- a/gcc/config/moxie/rtems.h
+++ b/gcc/config/moxie/rtems.h
@@ -33,6 +33,16 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#undef LINK_SPEC
#undef SIZE_TYPE
#undef PTRDIFF_TYPE
diff --git a/gcc/config/moxie/uclinux.h b/gcc/config/moxie/uclinux.h
index 9478aaf..7c3da7e 100644
--- a/gcc/config/moxie/uclinux.h
+++ b/gcc/config/moxie/uclinux.h
@@ -30,6 +30,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#undef TARGET_LIBC_HAS_FUNCTION
#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
diff --git a/gcc/config/nds32/linux.h b/gcc/config/nds32/linux.h
index b8ba05c..a809afd 100644
--- a/gcc/config/nds32/linux.h
+++ b/gcc/config/nds32/linux.h
@@ -36,6 +36,11 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#ifdef TARGET_BIG_ENDIAN_DEFAULT
#define LD_SO_ENDIAN_SPEC "%{mlittle-endian:le}%{!mlittle-endian:be}"
#else
diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h
index 59e8f37..b5fbb44 100644
--- a/gcc/config/netbsd.h
+++ b/gcc/config/netbsd.h
@@ -29,6 +29,15 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+/* TARGET_RUST_OS_INFO() common to all NetBSD targets. */
+#define NETBSD_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "netbsd"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* CPP_SPEC parts common to all NetBSD targets. */
#define NETBSD_CPP_SPEC \
"%{posix:-D_POSIX_SOURCE} \
diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
index 4bdcdcc..bbc32cf 100644
--- a/gcc/config/nios2/linux.h
+++ b/gcc/config/nios2/linux.h
@@ -26,6 +26,11 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
diff --git a/gcc/config/nios2/rtems.h b/gcc/config/nios2/rtems.h
index db66a5b..d24c2c7 100644
--- a/gcc/config/nios2/rtems.h
+++ b/gcc/config/nios2/rtems.h
@@ -32,6 +32,16 @@ do { \
builtin_assert ("system=rtems"); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* This toolchain implements the ABI for Linux Systems documented in the
Nios II Processor Reference Handbook.
diff --git a/gcc/config/openbsd.h b/gcc/config/openbsd.h
index c99aac6..4660aed 100644
--- a/gcc/config/openbsd.h
+++ b/gcc/config/openbsd.h
@@ -102,6 +102,14 @@ while (0)
} \
while (0)
+#define OPENBSD_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "openbsd"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while(0)
+
/* CPP_SPEC appropriate for OpenBSD. We deal with -posix and -pthread.
XXX the way threads are handled currently is not very satisfying,
since all code must be compiled with -pthread to work.
diff --git a/gcc/config/or1k/linux.h b/gcc/config/or1k/linux.h
index 21cef06..20b33fd 100644
--- a/gcc/config/or1k/linux.h
+++ b/gcc/config/or1k/linux.h
@@ -27,6 +27,8 @@
#define TARGET_OS_CPP_BUILTINS() \
GNU_USER_TARGET_OS_CPP_BUILTINS ()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-or1k.so.1"
#undef MUSL_DYNAMIC_LINKER
diff --git a/gcc/config/or1k/rtems.h b/gcc/config/or1k/rtems.h
index d4b8fef..a3a79f3 100644
--- a/gcc/config/or1k/rtems.h
+++ b/gcc/config/or1k/rtems.h
@@ -29,5 +29,19 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (or1k) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#define RTEMS_STARTFILE_SPEC "crtbegin%O%s"
#define RTEMS_ENDFILE_SPEC "crtend%O%s"
+
diff --git a/gcc/config/pa/pa-hpux.h b/gcc/config/pa/pa-hpux.h
index f5a88a4..abfb826 100644
--- a/gcc/config/pa/pa-hpux.h
+++ b/gcc/config/pa/pa-hpux.h
@@ -89,6 +89,18 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in pa-hpux.h (pa) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: rustc has no supported for hp-ux, so this is subject to change (and guessed)*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "hpux"); \
+ builtin_rust_info ("target_vendor", "hp"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Like the default, except no -lg. */
#undef LIB_SPEC
#define LIB_SPEC "%{!shared:%{!p:%{!pg:-lc}}%{p: -L/lib/libp/ -lc}%{pg: -L/lib/libp/ -lc}}"
diff --git a/gcc/config/pa/pa-hpux10.h b/gcc/config/pa/pa-hpux10.h
index 1aa5f87..22e1ea2 100644
--- a/gcc/config/pa/pa-hpux10.h
+++ b/gcc/config/pa/pa-hpux10.h
@@ -90,6 +90,18 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in pa-hpux10.h (pa) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: rustc has no supported for hp-ux, so this is subject to change (and guessed)*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "hpux"); \
+ builtin_rust_info ("target_vendor", "hp"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#define CPP_SPEC "%{threads: -D_REENTRANT -D_DCE_THREADS}"
/* We can debug dynamically linked executables on hpux9; we also want
diff --git a/gcc/config/pa/pa-hpux11.h b/gcc/config/pa/pa-hpux11.h
index 2820720..bc7e653 100644
--- a/gcc/config/pa/pa-hpux11.h
+++ b/gcc/config/pa/pa-hpux11.h
@@ -119,6 +119,18 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in pa-hpux11.h (pa) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: rustc has no supported for hp-ux, so this is subject to change (and guessed)*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "hpux"); \
+ builtin_rust_info ("target_vendor", "hp"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC \
"%{mt|pthread:-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L}"
diff --git a/gcc/config/pa/pa-linux.h b/gcc/config/pa/pa-linux.h
index 1326df0..f3bf763 100644
--- a/gcc/config/pa/pa-linux.h
+++ b/gcc/config/pa/pa-linux.h
@@ -27,6 +27,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in pa-linux.h (pa) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
diff --git a/gcc/config/pa/pa-netbsd.h b/gcc/config/pa/pa-netbsd.h
index 567a708..20b796b 100644
--- a/gcc/config/pa/pa-netbsd.h
+++ b/gcc/config/pa/pa-netbsd.h
@@ -27,6 +27,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in pa-netbsd.h (pa) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC NETBSD_CPP_SPEC
diff --git a/gcc/config/pa/pa-openbsd.h b/gcc/config/pa/pa-openbsd.h
index 4a56e91..be0b4b9 100644
--- a/gcc/config/pa/pa-openbsd.h
+++ b/gcc/config/pa/pa-openbsd.h
@@ -27,6 +27,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in pa-openbsd.h (pa) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ OPENBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Our profiling scheme doesn't LP labels and counter words. */
#define NO_DEFERRED_PROFILE_COUNTERS 1
diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
index b3eb81d7..64e792a 100644
--- a/gcc/config/pa/pa.h
+++ b/gcc/config/pa/pa.h
@@ -199,6 +199,8 @@ do { \
} \
while (0)
+/* TODO: is a TARGET_RUST_OS_INFO() required here? probably not */
+
#define CC1_SPEC "%{pg:} %{p:}"
#define LINK_SPEC "%{mlinker-opt:-O} %{!shared:-u main} %{shared:-b}"
diff --git a/gcc/config/phoenix.h b/gcc/config/phoenix.h
index c05d8f0..b90c660 100644
--- a/gcc/config/phoenix.h
+++ b/gcc/config/phoenix.h
@@ -26,6 +26,18 @@ along with GCC; see the file COPYING3. If not see
builtin_assert ("system=unix"); \
} while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in phoenix.h - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "phoenix"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ /*TODO: ensure these values are correct*/ \
+ } while(0)
+
#define STD_LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
/* This will prevent selecting 'unsigned long int' instead of 'unsigned int' as 'uint32_t' in stdint-newlib.h. */
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 4afef7c..3c4c378 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -22,6 +22,11 @@ along with GCC; see the file COPYING3. If not see
GNU_USER_TARGET_OS_CPP_BUILTINS(); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
#define MUSL_ABI_SUFFIX \
diff --git a/gcc/config/riscv/rtems.h b/gcc/config/riscv/rtems.h
index d222ab7..5de7027 100644
--- a/gcc/config/riscv/rtems.h
+++ b/gcc/config/riscv/rtems.h
@@ -29,3 +29,16 @@
builtin_define ("__USE_INIT_FINI__"); \
builtin_assert ("system=rtems"); \
} while (0)
+
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (riscv) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
index edd6fdb..f528330 100644
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
@@ -168,6 +168,16 @@
} \
while (0)
+#define AIX_TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for aix, so this is just guessed from triple*/ \
+ /*target_vendor is subject to change (and target_env to a lesser extent)*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "aix"); \
+ builtin_rust_info ("target_vendor", "ibm"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Define appropriate architecture macros for preprocessor depending on
target switches. */
diff --git a/gcc/config/rs6000/aix61.h b/gcc/config/rs6000/aix61.h
index 5b652d7..690f395 100644
--- a/gcc/config/rs6000/aix61.h
+++ b/gcc/config/rs6000/aix61.h
@@ -110,6 +110,14 @@ do { \
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in aix61.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ AIX_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%{posix: -D_POSIX_SOURCE} \
%{ansi: -D_ANSI_C_SOURCE} \
diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h
index 8b12a2d..f74913e 100644
--- a/gcc/config/rs6000/aix71.h
+++ b/gcc/config/rs6000/aix71.h
@@ -112,6 +112,14 @@ do { \
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in aix71.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ AIX_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#define CPP_SPEC32 ""
#define CPP_SPEC64 "-D__64BIT__"
#define CPP_SPEC_COMMON "%{posix: -D_POSIX_SOURCE} \
diff --git a/gcc/config/rs6000/aix72.h b/gcc/config/rs6000/aix72.h
index 121420b..62c2f87 100644
--- a/gcc/config/rs6000/aix72.h
+++ b/gcc/config/rs6000/aix72.h
@@ -113,6 +113,14 @@ do { \
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in aix72.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ AIX_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#define CPP_SPEC32 ""
#define CPP_SPEC64 "-D__64BIT__"
#define CPP_SPEC_COMMON "%{posix: -D_POSIX_SOURCE} \
diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h
index ce27508..54e1829 100644
--- a/gcc/config/rs6000/darwin.h
+++ b/gcc/config/rs6000/darwin.h
@@ -74,6 +74,16 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ /*TODO: rust actually has "macos", "ios", and "tvos" for darwin targets, but gcc seems to have no*/ \
+ /*current support for them, so assuming that target_os is always macos for now*/ \
+ builtin_rust_info ("target_os", "macos"); \
+ builtin_rust_info ("target_vendor", "apple"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#define SUBTARGET_OVERRIDE_OPTIONS darwin_rs6000_override_options ()
#define C_COMMON_OVERRIDE_OPTIONS do { \
diff --git a/gcc/config/rs6000/eabi.h b/gcc/config/rs6000/eabi.h
index b4e9dba..ebb2ac6 100644
--- a/gcc/config/rs6000/eabi.h
+++ b/gcc/config/rs6000/eabi.h
@@ -39,3 +39,15 @@
TARGET_OS_SYSV_CPP_BUILTINS (); \
} \
while (0)
+
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in eabi.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: values here are assumed from rustc's "bare metal" template*/ \
+ builtin_rust_info ("target_family", ""); \
+ builtin_rust_info ("target_os", "none"); \
+ builtin_rust_info ("target_vendor", ""); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/rs6000/eabisim.h b/gcc/config/rs6000/eabisim.h
index 14fd9ac..37cfeb6 100644
--- a/gcc/config/rs6000/eabisim.h
+++ b/gcc/config/rs6000/eabisim.h
@@ -34,6 +34,18 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in eabisim.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: values here are assumed from rustc's "bare metal" template*/ \
+ builtin_rust_info ("target_family", ""); \
+ builtin_rust_info ("target_os", "none"); \
+ builtin_rust_info ("target_vendor", ""); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Make the simulator the default */
#undef LIB_DEFAULT_SPEC
#define LIB_DEFAULT_SPEC "%(lib_sim)"
diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index b7026fc..793eb00 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -59,6 +59,14 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in linux.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_OS_DEFAULT_SPEC
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 73b6c01..4bbb3f3 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -314,6 +314,14 @@ extern int dot_symbols;
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in linux64.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_OS_DEFAULT_SPEC
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux) %(include_extra)"
diff --git a/gcc/config/rs6000/lynx.h b/gcc/config/rs6000/lynx.h
index 28f439a..5d9f488 100644
--- a/gcc/config/rs6000/lynx.h
+++ b/gcc/config/rs6000/lynx.h
@@ -71,6 +71,18 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in lynx.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: not supported by rustc and so subject to change - based on llvm triple*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "lynxos"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* LynxOS does not do anything with .fixup plus let's not create
writable section for linkonce.r and linkonce.t. */
diff --git a/gcc/config/rs6000/netbsd.h b/gcc/config/rs6000/netbsd.h
index 576b20f..8cfcbb4 100644
--- a/gcc/config/rs6000/netbsd.h
+++ b/gcc/config/rs6000/netbsd.h
@@ -34,6 +34,14 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in netbsd.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Override the default from rs6000.h to avoid conflicts with macros
defined in NetBSD header files. */
diff --git a/gcc/config/rs6000/rtems.h b/gcc/config/rs6000/rtems.h
index 40db660..e928657 100644
--- a/gcc/config/rs6000/rtems.h
+++ b/gcc/config/rs6000/rtems.h
@@ -72,6 +72,19 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtems.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Copy and paste from linux64.h and freebsd64.h */
#undef RELOCATABLE_NEEDS_FIXUP
#define RELOCATABLE_NEEDS_FIXUP \
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index 9ade721..0e3020c 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -548,6 +548,19 @@ extern int fixuplabelno;
while (0)
#endif
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in sysv4.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: everything in here is just guessed from gcc triples and assumptions - nothing really*/ \
+ /*targets system v anymore so hard to find info on it. as such, everything subject to change*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "sysv4"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Select one of BIG_OPT, LITTLE_OPT or DEFAULT_OPT depending
on various -mbig, -mlittle and -mcall- options. */
#define ENDIAN_SELECT(BIG_OPT, LITTLE_OPT, DEFAULT_OPT) \
diff --git a/gcc/config/rs6000/vxworks.h b/gcc/config/rs6000/vxworks.h
index 51a3250..c5f690b 100644
--- a/gcc/config/rs6000/vxworks.h
+++ b/gcc/config/rs6000/vxworks.h
@@ -103,6 +103,13 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in vxworks.h (rs6000) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ VXWORKS_TARGET_RUST_OS_INFO (); \
+ } while (0)
#define VX_CPUDEF(CPUID) \
":-D" VX_CPU_PREFIX "CPU=" VX_CPU_PREFIX #CPUID
diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
index 6919b46..ca90e05 100644
--- a/gcc/config/s390/linux.h
+++ b/gcc/config/s390/linux.h
@@ -48,6 +48,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Target specific assembler settings. */
/* Rewrite -march=arch* options to the original CPU name in order to
diff --git a/gcc/config/s390/tpf.h b/gcc/config/s390/tpf.h
index 22adf27..208236d 100644
--- a/gcc/config/s390/tpf.h
+++ b/gcc/config/s390/tpf.h
@@ -69,6 +69,19 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in tpf.h (s390) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: everything in here is just guessed from gcc triples as rustc has no support*/ \
+ /*as such, stuff subject to change*/ \
+ builtin_rust_info ("target_family", ""); \
+ builtin_rust_info ("target_os", "tpf"); \
+ builtin_rust_info ("target_vendor", "ibm"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
#define EXTRA_SPECS \
{ "entry_spec", ENTRY_SPEC }
diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
index c1d0441..0711d01 100644
--- a/gcc/config/sh/linux.h
+++ b/gcc/config/sh/linux.h
@@ -37,6 +37,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef TARGET_DEFAULT
#define TARGET_DEFAULT \
(TARGET_CPU_DEFAULT | TARGET_ENDIAN_DEFAULT | TARGET_OPT_DEFAULT)
diff --git a/gcc/config/sh/netbsd-elf.h b/gcc/config/sh/netbsd-elf.h
index 02bf1be..0aaa8c0 100644
--- a/gcc/config/sh/netbsd-elf.h
+++ b/gcc/config/sh/netbsd-elf.h
@@ -35,6 +35,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Provide a LINK_SPEC appropriate for a NetBSD/sh ELF target.
We use the SH_LINK_SPEC from sh/sh.h, and define the appropriate
SUBTARGET_LINK_SPEC that pulls in what we need from a generic
diff --git a/gcc/config/sh/rtems.h b/gcc/config/sh/rtems.h
index 7161817..f41038c 100644
--- a/gcc/config/sh/rtems.h
+++ b/gcc/config/sh/rtems.h
@@ -29,3 +29,13 @@
builtin_define( "__rtems__" ); \
builtin_assert( "system=rtems" ); \
} while (0)
+
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/sh/rtemself.h b/gcc/config/sh/rtemself.h
index a1aaa46..6004e15 100644
--- a/gcc/config/sh/rtemself.h
+++ b/gcc/config/sh/rtemself.h
@@ -29,3 +29,13 @@
builtin_define( "__rtems__" ); \
builtin_assert( "system=rtems" ); \
} while (0)
+
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
diff --git a/gcc/config/sh/vxworks.h b/gcc/config/sh/vxworks.h
index f3342c7..6b0c14d 100644
--- a/gcc/config/sh/vxworks.h
+++ b/gcc/config/sh/vxworks.h
@@ -28,6 +28,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ VXWORKS_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#undef SUBTARGET_OVERRIDE_OPTIONS
#define SUBTARGET_OVERRIDE_OPTIONS \
do \
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index 7a21f22..09ca1ee 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -124,6 +124,16 @@ along with GCC; see the file COPYING3. If not see
solaris_override_options (); \
} while (0)
+#define EXTRA_TARGET_RUST_OS_INFO()
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "solaris"); \
+ builtin_rust_info ("target_vendor", "sun"); \
+ builtin_rust_info ("target_env", ""); \
+ EXTRA_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#if DEFAULT_ARCH32_P
#define MULTILIB_DEFAULTS { "m32" }
#else
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 63853e6..9825626 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -27,6 +27,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
GNU_USER_TARGET_ENDFILE_SPEC \
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index 19ce84d..9655d46 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -30,6 +30,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ GNU_USER_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* On Linux, the combination sparc64-* --with-cpu=v8 is supported and
selects a 32-bit compiler. */
#if defined(TARGET_64BIT_DEFAULT) && TARGET_CPU_DEFAULT >= TARGET_CPU_v9
diff --git a/gcc/config/sparc/netbsd-elf.h b/gcc/config/sparc/netbsd-elf.h
index e37ece5..d4716a8 100644
--- a/gcc/config/sparc/netbsd-elf.h
+++ b/gcc/config/sparc/netbsd-elf.h
@@ -35,6 +35,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* CPP defines used by all NetBSD targets. */
#undef CPP_SUBTARGET_SPEC
#define CPP_SUBTARGET_SPEC "%(netbsd_cpp_spec)"
diff --git a/gcc/config/sparc/openbsd64.h b/gcc/config/sparc/openbsd64.h
index f700ecd..222c12e 100644
--- a/gcc/config/sparc/openbsd64.h
+++ b/gcc/config/sparc/openbsd64.h
@@ -41,6 +41,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ OPENBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef ASM_SPEC
#define ASM_SPEC "\
-s %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
diff --git a/gcc/config/sparc/rtemself.h b/gcc/config/sparc/rtemself.h
index 6570590..9caec89 100644
--- a/gcc/config/sparc/rtemself.h
+++ b/gcc/config/sparc/rtemself.h
@@ -36,5 +36,18 @@
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in rtemself.h (sparc) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Use the default */
#undef LINK_GCC_C_SEQUENCE_SPEC
diff --git a/gcc/config/sparc/vxworks.h b/gcc/config/sparc/vxworks.h
index 23c56b8..3b0427c 100644
--- a/gcc/config/sparc/vxworks.h
+++ b/gcc/config/sparc/vxworks.h
@@ -27,6 +27,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ VXWORKS_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#undef SUBTARGET_OVERRIDE_OPTIONS
#define SUBTARGET_OVERRIDE_OPTIONS VXWORKS_OVERRIDE_OPTIONS
diff --git a/gcc/config/tilegx/linux.h b/gcc/config/tilegx/linux.h
index f9d129a..20e82a6 100644
--- a/gcc/config/tilegx/linux.h
+++ b/gcc/config/tilegx/linux.h
@@ -18,6 +18,12 @@
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: ensure that this is all that needs to be defined*/ \
+ GNU_USER_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%{pthread:-D_REENTRANT}"
diff --git a/gcc/config/tilepro/linux.h b/gcc/config/tilepro/linux.h
index 25292b0..fb5da5d 100644
--- a/gcc/config/tilepro/linux.h
+++ b/gcc/config/tilepro/linux.h
@@ -18,6 +18,12 @@
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*TODO: ensure that this is all that needs to be defined*/ \
+ GNU_USER_TARGET_RUST_OS_INFO (); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%{pthread:-D_REENTRANT}"
diff --git a/gcc/config/v850/rtems.h b/gcc/config/v850/rtems.h
index e261ea3..d23840f 100644
--- a/gcc/config/v850/rtems.h
+++ b/gcc/config/v850/rtems.h
@@ -32,6 +32,16 @@
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc has no supported for rtems, so this is just guessed*/ \
+ /*everything is subject to change, especially target_env and target_family*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "rtems"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", ""); \
+ } while (0)
+
/* Map mv850e1 and mv850es to mv850e to match MULTILIB_MATCHES */
#undef ASM_SPEC
#define ASM_SPEC "%{mv850es:-mv850e} \
diff --git a/gcc/config/vax/linux.h b/gcc/config/vax/linux.h
index 2addf7d..46b2e9c 100644
--- a/gcc/config/vax/linux.h
+++ b/gcc/config/vax/linux.h
@@ -20,6 +20,8 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
/* We use GAS, G-float double and want new DI patterns. */
#undef TARGET_DEFAULT
#define TARGET_DEFAULT (MASK_QMATH | MASK_G_FLOAT)
diff --git a/gcc/config/vax/netbsd-elf.h b/gcc/config/vax/netbsd-elf.h
index 26b98ef..1a9590b 100644
--- a/gcc/config/vax/netbsd-elf.h
+++ b/gcc/config/vax/netbsd-elf.h
@@ -27,6 +27,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in netbsd-elf.h (vax) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ NETBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC NETBSD_CPP_SPEC
diff --git a/gcc/config/vax/openbsd.h b/gcc/config/vax/openbsd.h
index b733e8c..65a0104 100644
--- a/gcc/config/vax/openbsd.h
+++ b/gcc/config/vax/openbsd.h
@@ -29,6 +29,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ OPENBSD_TARGET_RUST_OS_INFO(); \
+ } while (0)
+
/* Layout of source language data types. */
/* This must agree with <machine/ansi.h> */
diff --git a/gcc/config/vms/vms.h b/gcc/config/vms/vms.h
index f663f0f..be323de 100644
--- a/gcc/config/vms/vms.h
+++ b/gcc/config/vms/vms.h
@@ -38,6 +38,19 @@ along with GCC; see the file COPYING3. If not see
builtin_define_with_int_value ("__VMS_VER", vms_c_get_vms_ver ()); \
} while (0)
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*target_family (and others) are subject to change - no support by rustc so unknown values - TODO*/ \
+ /*target_family written as unix because of supposed POSIX-compliance*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "vms"); \
+ /*target_vendor written as unknown because i don't know what it would be (maybe HP?)*/ \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ /*target_env is empty as not a gnu target environment*/ \
+ builtin_rust_info ("target_env", ""); \
+ SUBTARGET_RUST_OS_INFO(); \
+ } while (0)
+
extern void vms_c_register_includes (const char *, const char *, int);
#define TARGET_EXTRA_INCLUDES vms_c_register_includes
diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index e2ce22b..0dfafd6 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -265,6 +265,14 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority);
} \
while (0)
+#define VXWORKS_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "vxworks"); \
+ builtin_rust_info ("target_vendor", "wrs"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ } while (0)
+
/* For specific CPU macro definitions expected by the system headers,
different versions of VxWorks expect different forms of macros,
such as "_VX_CPU=..." on Vx7 and some variants of Vx6, or "CPU=..."
diff --git a/gcc/config/vxworksae.h b/gcc/config/vxworksae.h
index 7509931..94c2049 100644
--- a/gcc/config/vxworksae.h
+++ b/gcc/config/vxworksae.h
@@ -73,6 +73,15 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define VXWORKS_TARGET_RUST_OS_INFO() \
+ do { \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "vxworks"); \
+ builtin_rust_info ("target_vendor", "wrs"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ /*is env correct? vxworks.h implies that this might not come with a gnu toolchain*/ \
+ } while (0)
+
/* Do VxWorks-specific parts of TARGET_OPTION_OVERRIDE. */
/* None of the VxWorks AE/653/MILS ports to date has native TLS support. */
diff --git a/gcc/config/xtensa/linux.h b/gcc/config/xtensa/linux.h
index bd20595..5f54c7a 100644
--- a/gcc/config/xtensa/linux.h
+++ b/gcc/config/xtensa/linux.h
@@ -20,6 +20,8 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
+#define TARGET_RUST_OS_INFO() GNU_USER_TARGET_RUST_OS_INFO()
+
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
diff --git a/gcc/config/xtensa/uclinux.h b/gcc/config/xtensa/uclinux.h
index 374d2947..f955187 100644
--- a/gcc/config/xtensa/uclinux.h
+++ b/gcc/config/xtensa/uclinux.h
@@ -27,6 +27,19 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#ifdef TARGET_RUST_OS_INFO
+# error "TARGET_RUST_OS_INFO already defined in uclinux.h (xtensa) - c++ undefines it and redefines it."
+#endif
+#define TARGET_RUST_OS_INFO() \
+ do { \
+ /*note: as far as I know, rustc does not distinguish between uclinux and regular linux kernels*/ \
+ builtin_rust_info ("target_family", "unix"); \
+ builtin_rust_info ("target_os", "linux"); \
+ builtin_rust_info ("target_vendor", "unknown"); \
+ builtin_rust_info ("target_env", "gnu"); \
+ /*TODO: is GNU_USER_TARGET_RUST_OS_INFO() better here or is hardcoded stuff fine?*/ \
+ } while (0)
+
#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc
index d82e6d8..c3ae4da 100644
--- a/gcc/rust/rust-lang.cc
+++ b/gcc/rust/rust-lang.cc
@@ -42,6 +42,8 @@
#include "rust-parse.h"
#include "rust-session-manager.h"
+#include "rust-target.h"
+
// Language-dependent contents of a type. GTY() mark used for garbage collector.
struct GTY(()) lang_type {
char dummy;
@@ -74,6 +76,11 @@ struct GTY(()) language_function {
// Kinda HACK-ish - store parsing session as static variable
static Rust::Session session;
+// has to be in same compilation unit as session, so here for now
+void rust_add_target_info(const char* key, const char* value) {
+ session.options.target_data.insert_key_value_pair(key, value);
+}
+
/* Language hooks. */
/* Initial lang hook called (possibly), used for initialisation.
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 471a7fa..a52e1a5 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -3,9 +3,14 @@
#include "diagnostic.h"
#include "input.h"
+#include "target.h"
+#include "tm.h"
+
#include "rust-lex.h"
#include "rust-parse.h"
+#include "rust-target.h"
+
#include <algorithm>
extern Linemap* rust_get_linemap();
@@ -193,7 +198,13 @@ namespace Rust {
}
void Session::init() {
- // nothing yet
+# define builtin_rust_info(KEY, VALUE) rust_add_target_info (KEY, VALUE)
+
+ // initialise target hooks
+ targetrustm.rust_cpu_info();
+ targetrustm.rust_os_info();
+
+#undef builtin_rust_info
}
// Initialise default options. Actually called before handle_option, unlike init itself.
@@ -428,7 +439,7 @@ namespace Rust {
}
// TODO: move somewhere else
- bool contains_name(::std::vector<AST::Attribute> attrs, ::std::string name) {
+ bool contains_name(const std::vector<AST::Attribute>& attrs, std::string name) {
for (const auto& attr : attrs) {
if (attr.get_path() == name) {
return true;
diff --git a/gcc/rust/rust-target-def.h b/gcc/rust/rust-target-def.h
new file mode 100644
index 0000000..d64bbce
--- /dev/null
+++ b/gcc/rust/rust-target-def.h
@@ -0,0 +1,20 @@
+/* rust-target-def.h -- Default initializers for Rust target hooks.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+#include "rust/rust-target-hooks-def.h"
+#include "tree.h"
+#include "hooks.h"
diff --git a/gcc/rust/rust-target.def b/gcc/rust/rust-target.def
new file mode 100644
index 0000000..3f375cb
--- /dev/null
+++ b/gcc/rust/rust-target.def
@@ -0,0 +1,89 @@
+/* rust-target.def -- Target hook definitions for the Rust front end.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+/* See target-hooks-macros.h for details of macros that should be
+ provided by the including file, and how to use them here. */
+
+#include "target-hooks-macros.h"
+
+#undef HOOK_TYPE
+#define HOOK_TYPE "Rust Target Hook"
+
+HOOK_VECTOR (TARGETRUSTM_INITIALIZER, gcc_targetrustm)
+
+#undef HOOK_PREFIX
+#define HOOK_PREFIX "TARGET_"
+
+/* Environmental CPU info and features (e.g. endianness, pointer size) relating to the target CPU. */
+DEFHOOK
+(rust_cpu_info,
+ "Declare all environmental CPU info and features relating to the target CPU\n\
+using the function @code{rust_add_target_info}, which takes a string representing\n\
+the feature key and a string representing the feature value. Configuration pairs\n\
+predefined by this hook apply to all files that are being compiled.",
+ void, (void),
+ hook_void_void)
+
+// TODO: remove: format of DEFHOOK is return type, (param types), default value for function that it translates to
+
+/* Environmental OS info relating to the target OS. */
+DEFHOOK
+(/*d_os_versions*/rust_os_info,
+ "Similarly to @code{TARGET_RUST_CPU_INFO}, but is used for configuration info\n\
+relating to the target operating system.",
+ void, (void),
+ hook_void_void)
+
+/* The sizeof CRITICAL_SECTION or pthread_mutex_t. */
+/*DEFHOOK
+(d_critsec_size,
+ "Returns the size of the data structure used by the target operating system\n\
+for critical sections and monitors. For example, on Microsoft Windows this\n\
+would return the @code{sizeof(CRITICAL_SECTION)}, while other platforms that\n\
+implement pthreads would return @code{sizeof(pthread_mutex_t)}.",
+ unsigned, (void),
+ hook_uint_void_0)*/
+
+ /* TODO: add more if required. Possible ones include static C runtime, target_env
+ * or vendor (if not covered by OS), and flags from the driver that may or may not
+ * require a target hook (might instead require a different type of hook) like
+ * test, debug_assertions, and proc_macro. */
+
+ /* TODO: rustc target support by tier:
+ * Tier 1 (definitely work):
+ * - i686-pc-windows-gnu
+ * - i686-pc-windows-msvc
+ * - i686-unknown-linux-gnu
+ * - x86_64-apple-darwin
+ * - x86_64-pc-windows-gnu
+ * - x86_64-pc-windows-msvc
+ * - x86_64-unknown-linux-gnu
+ * - Basically, 32-bit and 64-bit x86 for windows (MinGW and MSVC), gnu/linux, and osx
+ * Other tiers have too much crap, but basic breakdown is:
+ * Tier 2:
+ * - archs: ARM64 (aarch64), ARMv7, ARMv6, asm.js, i586 (32-bit x86 without SSE), mips,
+ * mips64, powerpc, powerpc64, risc-v, s390x, sparc, webasm, netbsd, redox (does gcc have support?),
+ * cloudabi (never head of it; i imagine no gcc support)
+ * - oses: ios, fuchsia, android, windows (msvc and mingw), gnu/linux, freebsd, netbsd
+ * Tier 2.5:
+ * - powerpc SPE linux, various cloudabi stuff, sparc
+ * Tier 3:
+ * - more obscure stuff like UWP support, vxworks, openbsd, dragonflybsd, haiku, bitrig, windows xp,
+ * cuda, hexagon, and combinations of them and earlier stuff */
+
+/* Close the 'struct gcc_targetrustm' definition. */
+HOOK_VECTOR_END (C90_EMPTY_HACK)
diff --git a/gcc/rust/rust-target.h b/gcc/rust/rust-target.h
new file mode 100644
index 0000000..b6edbd3
--- /dev/null
+++ b/gcc/rust/rust-target.h
@@ -0,0 +1,40 @@
+/* rust-target.h -- Data structure definitions for target-specific Rust behavior.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_RUST_TARGET_H
+#define GCC_RUST_TARGET_H
+
+// TODO: find out what this stuff actually does
+#define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
+#define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
+#define DEFHOOK_UNDOC DEFHOOK
+#define HOOKSTRUCT(FRAGMENT) FRAGMENT
+
+#include "rust-target.def"
+
+/* Each target can provide their own. */
+extern struct gcc_targetrustm targetrustm;
+/* Some kind of structure to store all rust hook macros (like the TARGET_RUST_CPU_INFO).
+ * This is required to store the function pointers for the target hooks so that the frontend can call them
+ * and it calls the correct target-specific function. */
+
+/* Used by target to add predefined version idenditiers. */
+//extern void d_add_builtin_version (const char *);
+/* Used by target to add target-related info. */
+extern void rust_add_target_info(const char* key, const char* value);
+
+#endif \ No newline at end of file