Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i386-plan9 target support for gcc 4.8.3 from https://marcus.biz.tm/fi… #3

Open
wants to merge 1 commit into
base: releases/gcc-4.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.sub
Expand Up @@ -1376,7 +1376,7 @@ case $os in
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -plan9*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
Expand Down
3 changes: 3 additions & 0 deletions configure
Expand Up @@ -3395,6 +3395,9 @@ case "${target}" in
i[3456789]86-*-mingw*)
noconfigdirs="$noconfigdirs ${libgcj}"
;;
i[3456789]86-*-plan9*)
noconfigdirs="$noconfigdirs ${libgcj} target-libffi"
;;
x86_64-*-mingw*)
noconfigdirs="$noconfigdirs ${libgcj}"
;;
Expand Down
10 changes: 6 additions & 4 deletions gcc/Makefile.in
Expand Up @@ -445,7 +445,7 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
LTO_SYMTAB_H = $(srcdir)/../include/lto-symtab.h

# Default native SYSTEM_HEADER_DIR, to be overridden by targets.
NATIVE_SYSTEM_HEADER_DIR = @NATIVE_SYSTEM_HEADER_DIR@
NATIVE_SYSTEM_HEADER_DIR = /usr/pkg/include
# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@

Expand Down Expand Up @@ -1906,7 +1906,7 @@ collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
$(COLLECT2_OBJS) $(LIBS) $(COLLECT2_LIBS)
mv -f T$@ $@

CFLAGS-collect2.o += -DTARGET_MACHINE=\"$(target_noncanonical)\" \
CFLAGS-collect2.o += -fpermissive -DTARGET_MACHINE=\"$(target_noncanonical)\" \
@TARGET_SYSTEM_ROOT_DEFINE@
collect2.o : collect2.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h \
$(OBSTACK_H) $(DEMANGLE_H) collect2.h collect2-aix.h version.h \
Expand All @@ -1923,6 +1923,7 @@ lto-wrapper$(exeext): lto-wrapper.o ggc-none.o libcommon-target.a $(LIBDEPS)
lto-wrapper.o ggc-none.o libcommon-target.a $(LIBS)
mv -f T$@ $@

CFLAGS-lto-wrapper.o += -fpermissive
lto-wrapper.o: lto-wrapper.c $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h \
$(OBSTACK_H) $(DIAGNOSTIC_H) $(OPTS_H) $(OPTIONS_H)

Expand Down Expand Up @@ -2040,6 +2041,7 @@ DRIVER_DEFINES = \
`test "X$${SHLIB}" = "X" || test "@enable_shared@" != "yes" || echo "-DENABLE_SHARED_LIBGCC"` \
-DCONFIGURE_SPECS="\"@CONFIGURE_SPECS@\""

CFLAGS-gcc.o += -fpermissive
gcc.o: gcc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h multilib.h \
Makefile $(lang_specs_files) specs.h prefix.h $(GCC_H) $(FLAGS_H) \
configargs.h $(OBSTACK_H) $(OPTS_H) $(DIAGNOSTIC_H) $(VEC_H) $(PARAMS_H)
Expand Down Expand Up @@ -2689,7 +2691,7 @@ s-bversion: BASE-VER

input.o : input.c $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h $(INPUT_H)

CFLAGS-toplev.o += -DTARGET_NAME=\"$(target_noncanonical)\"
CFLAGS-toplev.o += -DTARGET_NAME=\"$(target_noncanonical)\" -fpermissive
toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
version.h $(RTL_H) $(FUNCTION_H) $(FLAGS_H) xcoffout.h $(INPUT_H) \
$(INSN_ATTR_H) output.h $(DIAGNOSTIC_H) debug.h insn-config.h intl.h \
Expand Down Expand Up @@ -3968,7 +3970,7 @@ $(genprogerr:%=build/gen%$(build_exeext)): $(BUILD_ERRORS)
genprog = $(genprogerr) check checksum condmd

# These programs need libs over and above what they get from the above list.
build/genautomata$(build_exeext) : BUILD_LIBS += -lm
build/genautomata$(build_exeext) : BUILD_LIBS += #-lm

# These programs are not linked with the MD reader.
build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
Expand Down
12 changes: 12 additions & 0 deletions gcc/config.gcc
Expand Up @@ -1228,6 +1228,18 @@ i[34567]86-*-freebsd*)
x86_64-*-freebsd*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/x86-64.h i386/freebsd.h i386/freebsd64.h"
;;
i[34567]86-*-plan9) # Plan9 386
tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h plan9.h i386/plan9.h"
tmake_file="${tmake_file}"
extra_options="${extra_options} plan9.opt"
case ${enable_threads} in
"" | yes | posix)
thread_file='posix'
;;
esac
gas=yes
use_collect2=yes
;;
i[34567]86-*-netbsdelf*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h"
extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
Expand Down
2 changes: 2 additions & 0 deletions gcc/config.host
Expand Up @@ -241,6 +241,8 @@ case ${host} in
echo "*** linking with posix.dll is not allowed by the GNU GPL."
exit 1
;;
i[34567]86-*-plan9*)
;;
i[34567]86-*-darwin* | x86_64-*-darwin*)
out_host_hook_obj="${out_host_hook_obj} host-i386-darwin.o"
host_xmake_file="${host_xmake_file} i386/x-darwin"
Expand Down
79 changes: 79 additions & 0 deletions gcc/config/i386/plan9.h
@@ -0,0 +1,79 @@
/* Target definitions for Intel 386 CPU running Plan 9

Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.

This file is part of GCC.

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.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */

/* Names to predefine in the preprocessor for this target machine. */

#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
builtin_define ("Plan9"); \
builtin_define ("PLAN9"); \
builtin_define ("__LITTLE_ENDIAN__"); \
builtin_define ("_POSIX_SOURCE"); \
builtin_define ("_LIMITS_EXTENSION"); \
builtin_define ("_BSD_EXTENSION"); \
builtin_define ("_SUSV2_SOURCE"); \
builtin_define ("_RESEARCH_SOURCE"); \
builtin_assert ("system=plan9"); \
} \
while (0)


/* If hosted on Plan 9, set standard directory paths accordingly.
* These definitions are target-specific.
*/

/* Looking for right place for c++ headers. Horrible hack, it should be
* specified at configure time, but I'm always forgetting it :(.
*/

#undef GPLUSPLUS_INCLUDE_DIR
#define GPLUSPLUS_INCLUDE_DIR "/usr/pkg/include/c++/4.8.3"

#undef LOCAL_INCLUDE_DIR
#define LOCAL_INCLUDE_DIR "/usr/pkg/include"

#undef NATIVE_SYSTEM_HEADER_DIR
#define NATIVE_SYSTEM_HEADER_DIR "/sys/include/ape"

#undef STANDARD_STARTFILE_PREFIX
#define STANDARD_STARTFILE_PREFIX "/usr/pkg/lib/"

/* The host-specific ones are here */

#undef STANDARD_EXEC_PREFIX
#define STANDARD_EXEC_PREFIX "/usr/pkg/bin/"

#undef STANDARD_BINDIR_PREFIX
#define STANDARD_BINDIR_PREFIX "/usr/pkg/bin/"

#define MD_EXEC_PREFIX "/usr/pkg/bin/"

#undef TOOLDIR_BASE_PREFIX
#define TOOLDIR_BASE_PREFIX "../../../usr/pkg/"

204 changes: 204 additions & 0 deletions gcc/config/plan9.h
@@ -0,0 +1,204 @@
/* Operating system specific defines to be used when targeting GCC
for Plan 9.

Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.

This file is part of GCC.

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.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */

/* LPREFIX should be defined by default '.L' att.h style. But gas.h does
* not define anything about that, and bsd.h has no option anymore since
* GCC 3.4; so setting up it by hand.
*/

#undef LPREFIX
#define LPREFIX ".L"

/* The prefix to add for compiler private assembler symbols. */

#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."

/* This is how to store into the string BUF
the symbol_ref name of an internal numbered label where
PREFIX is the class of label and NUM is the number within the class.
This is suitable for output with `assemble_name'. */

#undef ASM_GENERATE_INTERNAL_LABEL
#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \
sprintf ((BUF), "%s%s%ld", LOCAL_LABEL_PREFIX, (PREFIX), (long)(NUMBER))

/* Define the syntax of labels and symbol definitions/declarations.
* Overrides actual default in bsd.h; in previous GCC versions there was
* an option.
*/

#undef USER_LABEL_PREFIX
#define USER_LABEL_PREFIX ""

/* String containing the assembler's comment-starter.
* Note the trailing space is necessary in case the character
* that immediately follows the comment is '*'. If this happens
* and the space is not there the assembler will interpret this
* as the start of a C-like slash-star comment and complain when
* there is no terminator.
* Overriding gas.h, from unix.h.
*/

#undef ASM_COMMENT_START
#define ASM_COMMENT_START "/ "

/* No separate math library (no -lm). It's in ape/libc/math :) */

#define MATH_LIBRARY ""

/* Plan9 POSIX threads *
* ******************* */

/* Added libbsd and libpthread as a part of standard library, both are
* used by default. Check for shared because there are dummy shared flags
* during bootstrap or into another packages of sources made with
* autoconf.
*/

#undef LIB_SPEC
#define LIB_SPEC "%{!shared:%{pthread:-lpthread}} -lbsd -lc"

/* Every program on Plan 9 compiled with GCC links against libpthread.a
* which contains the pthread routines, so there's no need to explicitly
* call out when doing threaded work (-fopenmp / -fgnu-tm options imply
* pthreads in gcc.c).
*/

#undef GOMP_SELF_SPECS
#define GOMP_SELF_SPECS ""
#undef GTM_SELF_SPECS
#define GTM_SELF_SPECS ""

/* Need it by default unless you wan to type always -pthread option; libgcc,
* gfortran, g++ and others libs will use it by default. Specified in
* plan9.opt file. Default option removed except for AIX ad Solaris
* since GCC 4.6. Perhaps more options would be added to that file.
*/

#define DRIVER_SELF_SPECS "-pthread"

/* END Plan9 POSIX threads *
* *********************** */

/* Plan9 C++ *
* ********* */

/* Plan 9 linking with libstdc++ requires libsupc++ as well. */

#define LIBSTDCXX_STATIC "supc++"

/* More g++, forcing cc1/cc1plus to run Global CTORS/DTORS.
* If defined, 'main' will call '__main' despite the presence of
* 'INIT_SECTION_ASM_OP'.
* This macro should be defined for systems where the init section is
* not actually run automatically, but is still useful for collecting
* the lists of constructors and destructors. */

#define INVOKE__main

/* END Plan9 C++ *
* ************* */

/* Plan9 DBX Debug *
* *************** */

/* When generating stabs debugging, use N_BINCL entries SunOS style.
* --
* This is designed for ELF systems (dbxelf.h), but is not the only
* thing from dynamic linking that David Hogan included in his original
* port. I Don't know if he was trying to emit native code from Plan9
* for GNU binutils or planing a migration to ELF/dynamic linking some
* day. Perhaps in future it will be useful.
*/

#define DBX_USE_BINCL

/* There is no limit to the length of stabs strings. */

#define DBX_CONTIN_LENGTH 0

/* Generate a blank trailing N_SO to mark the end of the .o file, since
* we can't depend upon the linker to mark .o file boundaries with
* embedded stabs.
*/

#define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END

/* .file at the begining of the assembler source file.
* Default is false, but gas.h set to true. We return to false
* as David Hogan did for his Plan 9 GCC 3.0 port.
*/

#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
#define TARGET_ASM_FILE_START_FILE_DIRECTIVE false

/* END Plan9 DBX Debug *
* ******************* */

/* Policy about Named Sections in gas has been changed since gcc-4.5 times:
* http://gcc.gnu.org/ml/gcc-patches/2011-06/msg01642.html
*/

#define TARGET_HAVE_NAMED_SECTIONS false

/****************
* EXPERIMENTAL *
****************/

/* We need this since G++ is the default compiler. Avoiding possible
* issues about C++ system C headers compliance.
*/

#undef NO_IMPLICIT_EXTERN_C
#define NO_IMPLICIT_EXTERN_C

/* This was a warning with gcc 4.7, now things are more strict :(
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47099
*/

#undef ASM_DECLARE_FUNCTION_NAME
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
do { \
ASM_OUTPUT_FUNCTION_LABEL (FILE, NAME, DECL); \
} while (0)

/* Trying to avoid General Protection Fault in libcpp/lex.c by illegals movdqa
* in Plan 9.
* See in libcpp/lex.c how to bypass search_line_* functions for
* SSE2 and SSE4 (4.2).
*/

#undef ASM_QUAD

/* Don't default to pcc-struct-return, because gcc is the only compiler in its
* environment, and we want to retain compatibility with older gcc versions.
*/

#define DEFAULT_PCC_STRUCT_RETURN 0