S/390: (partially) fix -m31 / -m64 options
Ulrich Weigand
Ulrich.Weigand@de.ibm.com
Wed Feb 6 13:42:00 GMT 2002
Hello,
the -m31 / -m64 options are currently rather broken. This patch
gets them working at least partially: now at least the compiler
(incl. preprocessor) correctly switches its behaviour at run-time,
without any remaining build-time dependencies.
Some things that were broken: -m31 should not define __s390x__,
LONG_MAX was incorrect, MASK_RETURN_ADDR didn't work properly,
PTRDIFF_TYPE wasn't changed accordingly ...
To get a complete bi-arch build environment a few pieces are still
missing, most notably multilibbed 31- vs. 64-bit libgcc and crtstuff.
The patch also cleans up some additional bugs in the linux.h / linux64.h
target headers:
- LINK_SPEC should not add -rpath-link (if CROSS_COMPILE)
- LINK_SPEC should not reference -ibcs (which doesn't exist)
- linux64.h should not #undef SELECT_SECTION
One historical accident is still in: on 31-bit s390, SIZE_TYPE
is defined to be 'unsigned long', unlike most (all?) other 32-bit
Linux ports which use 'unsigned int'. I've left this as is for
now ...
ChangeLog:
* config/s390/linux64.h: Delete file.
* config/s390/s390x.h: New file.
* config.gcc (s390x-*-linux*): Use s390x.h instead of linux64.h
as target header file.
* config/s390/linux.h (TARGET_VERSION): Define depending on
DEFAULT_TARGET_64BIT.
(CPP_SPEC, ASM_SPEC, LINK_SPEC): Likewise.
(SIZE_TYPE, PTRDIFF_TYPE): Likewise.
(NO_BUILTIN_SIZE_TYPE, NO_BUILTIN_PTRDIFF_TYPE): Define.
(CPP_ARCH31_SPEC, CPP_ARCH64_SPEC): New defines.
(LINK_ARCH31_SPEC, LINK_ARCH64_SPEC): New defines.
(EXTRA_SPEC): New define.
* config/s390/s390.h (TARGET_VERSION): Define depending on
DEFAULT_TARGET_64BIT.
(MASK_RETURN_ADDR): Add run-time check for TARGET_64BIT.
Index: gcc/config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.159
diff -c -p -r1.159 config.gcc
*** config.gcc 2002/02/03 21:52:34 1.159
--- config.gcc 2002/02/06 20:29:17
*************** s390-*-linux*)
*** 2870,2876 ****
fi
;;
s390x-*-linux*)
! tm_file="s390/s390.h dbxelf.h elfos.h svr4.h linux.h s390/linux.h s390/linux64.h"
tm_p_file=s390/s390-protos.h
md_file=s390/s390.md
out_file=s390/s390.c
--- 2870,2876 ----
fi
;;
s390x-*-linux*)
! tm_file="s390/s390x.h s390/s390.h dbxelf.h elfos.h svr4.h linux.h s390/linux.h"
tm_p_file=s390/s390-protos.h
md_file=s390/s390.md
out_file=s390/s390.c
Index: gcc/config/s390/linux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/linux.h,v
retrieving revision 1.11
diff -c -p -r1.11 linux.h
*** linux.h 2002/01/08 13:11:23 1.11
--- linux.h 2002/02/06 20:29:26
***************
*** 1,5 ****
/* Definitions for Linux for S/390.
! Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Hartmut Penner (hpenner@de.ibm.com) and
Ulrich Weigand (uweigand@de.ibm.com).
--- 1,5 ----
/* Definitions for Linux for S/390.
! Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Hartmut Penner (hpenner@de.ibm.com) and
Ulrich Weigand (uweigand@de.ibm.com).
*************** Boston, MA 02111-1307, USA. */
*** 23,73 ****
#ifndef _LINUX_H
#define _LINUX_H
! #undef SIZE_TYPE /* use default */
! #undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (Linux for S/390)");
! /* Names to predefine in the preprocessor for this target machine. */
! #define CPP_PREDEFINES "-Dlinux -Asystem(linux) -Acpu(s390) -Amachine(s390) -D__s390__ -Asystem(unix) -Dunix -D__ELF__"
- /*
- * Caller save not (always) working in gcc-2.95.2
- */
! #undef CC1_SPEC
#define CC1_SPEC "-fno-caller-saves"
#define CC1PLUS_SPEC "-fno-caller-saves"
! #undef LINK_SPEC
! #ifdef CROSS_COMPILE
! #define LINK_SPEC "-m elf_s390 %{shared:-shared} \
! %{!shared: \
! %{!ibcs: \
%{!static: \
%{rdynamic:-export-dynamic} \
! %{!dynamic-linker:-dynamic-linker /lib/ld.so.1 \
! -rpath-link=/usr/local/s390-ibm-linux/lib}} \
! %{static:-static}}}"
! #else
! #define LINK_SPEC "-m elf_s390 %{shared:-shared} \
! %{!shared: \
! %{!ibcs: \
%{!static: \
%{rdynamic:-export-dynamic} \
! %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
! %{static:-static}}}"
#endif
- /* Need to define this. Otherwise define to BITS_PER_WORD in cexp.c.
- But BITS_PER_WORD depends on target flags, which are not defined in
- cexpc.c. */
! #undef WCHAR_TYPE
! #define WCHAR_TYPE "int"
! #undef WCHAR_TYPE_SIZE
! #define WCHAR_TYPE_SIZE 32
/* Character to start a comment. */
--- 23,136 ----
#ifndef _LINUX_H
#define _LINUX_H
! /* Target specific version string. */
! #ifdef DEFAULT_TARGET_64BIT
! #undef TARGET_VERSION
! #define TARGET_VERSION fprintf (stderr, " (Linux for zSeries)");
! #else
! #undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (Linux for S/390)");
+ #endif
+
+
+ /* Target specific type definitions. */
+
+ /* ??? Do we really want long as size_t on 31-bit? */
+ #undef SIZE_TYPE
+ #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "long unsigned int")
+ #undef PTRDIFF_TYPE
+ #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
+
+ #undef WCHAR_TYPE
+ #define WCHAR_TYPE "int"
+ #undef WCHAR_TYPE_SIZE
+ #define WCHAR_TYPE_SIZE 32
+
+
+ /* Target specific preprocessor settings. */
! #define NO_BUILTIN_SIZE_TYPE
! #define NO_BUILTIN_PTRDIFF_TYPE
! #define CPP_PREDEFINES \
! "-Dunix -Asystem(unix) -Dlinux -Asystem(linux) -D__ELF__ \
! -Acpu(s390) -Amachine(s390) -D__s390__"
!
! #define CPP_ARCH31_SPEC \
! "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=int"
! #define CPP_ARCH64_SPEC \
! "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
! -D__s390x__ -D__LONG_MAX__=9223372036854775807L"
!
! #ifdef DEFAULT_TARGET_64BIT
! #undef CPP_SPEC
! #define CPP_SPEC "%{m31:%(cpp_arch31)} %{!m31:%(cpp_arch64)}"
! #else
! #undef CPP_SPEC
! #define CPP_SPEC "%{m64:%(cpp_arch64)} %{!m64:%(cpp_arch31)}"
! #endif
! /* Target specific compiler settings. */
!
! /* ??? -fcaller-saves sometimes doesn't work. Fix this! */
! #undef CC1_SPEC
#define CC1_SPEC "-fno-caller-saves"
+ #undef CC1PLUS_SPEC
#define CC1PLUS_SPEC "-fno-caller-saves"
+
! /* Target specific assembler settings. */
!
! #ifdef DEFAULT_TARGET_64BIT
! #undef ASM_SPEC
! #define ASM_SPEC "%{m31:-m31 -Aesa}"
! #else
! #undef ASM_SPEC
! #define ASM_SPEC "%{m64:-m64 -Aesame}"
! #endif
!
!
! /* Target specific linker settings. */
!
! #define LINK_ARCH31_SPEC \
! "-m elf_s390 \
! %{shared:-shared} \
! %{!shared: \
! %{static:-static} \
%{!static: \
%{rdynamic:-export-dynamic} \
! %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}"
!
! #define LINK_ARCH64_SPEC \
! "-m elf64_s390 \
! %{shared:-shared} \
! %{!shared: \
! %{static:-static} \
%{!static: \
%{rdynamic:-export-dynamic} \
! %{!dynamic-linker:-dynamic-linker /lib/ld64.so.1}}}"
!
! #ifdef DEFAULT_TARGET_64BIT
! #undef LINK_SPEC
! #define LINK_SPEC "%{m31:%(link_arch31)} %{!m31:%(link_arch64)}"
! #else
! #undef LINK_SPEC
! #define LINK_SPEC "%{m64:%(link_arch64)} %{!m64:%(link_arch31)}"
#endif
! /* This macro defines names of additional specifications to put in the specs
! that can be used in various specifications like CC1_SPEC. Its definition
! is an initializer with a subgrouping for each command option. */
!
! #define EXTRA_SPECS \
! { "cpp_arch31", CPP_ARCH31_SPEC }, \
! { "cpp_arch64", CPP_ARCH64_SPEC }, \
! { "link_arch31", LINK_ARCH31_SPEC }, \
! { "link_arch64", LINK_ARCH64_SPEC }, \
!
/* Character to start a comment. */
Index: gcc/config/s390/linux64.h
===================================================================
RCS file: linux64.h
diff -N linux64.h
*** /sourceware/cvs-tmp/cvsIOvWhx Wed Feb 6 12:29:58 2002
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 1,65 ****
- /* Definitions for Linux for s/390 zSeries
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
- Contributed by Hartmut Penner (hpenner@de.ibm.com) and
- Ulrich Weigand (uweigand@de.ibm.com).
- This file is part of GNU CC.
-
- GNU CC 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 2, or (at your option)
- any later version.
-
- GNU CC 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 GNU CC; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
- #ifndef _LINUX64_H
- #define _LINUX64_H
-
- #undef PTRDIFF_TYPE
- #define PTRDIFF_TYPE "long int"
-
- #undef TARGET_DEFAULT
- #define TARGET_DEFAULT 0x13
-
- #undef TARGET_VERSION
- #define TARGET_VERSION fprintf (stderr, " (Linux for S/390 zSeries 64 bit)");
-
- /* Names to predefine in the preprocessor for this target machine. */
-
- #undef CPP_PREDEFINES
- #define CPP_PREDEFINES \
- "-Dlinux -Asystem(linux) -Acpu(s390) -Amachine(s390) -D__s390__ -D__s390x__ \
- -Asystem(unix) -Dunix -D__ELF__ \
- -D__LONG_MAX__=9223372036854775807L"
-
- #undef LINK_SPEC
- #ifdef CROSS_COMPILE
- #define LINK_SPEC "-m elf64_s390 %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib/ld64.so.1 \
- -rpath-link=/usr/local/s390x-ibm-linux/lib}} \
- %{static:-static}}}"
- #else
- #define LINK_SPEC "-m elf64_s390 %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib/ld64.so.1}} \
- %{static:-static}}}"
- #endif
-
- #undef MASK_RETURN_ADDR
- #undef SELECT_SECTION
-
- #endif
--- 0 ----
Index: gcc/config/s390/s390.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.h,v
retrieving revision 1.21
diff -c -p -r1.21 s390.h
*** s390.h 2002/02/04 15:51:18 1.21
--- s390.h 2002/02/06 20:29:31
*************** Boston, MA 02111-1307, USA. */
*** 22,29 ****
#ifndef _S390_H
#define _S390_H
- #define TARGET_VERSION fprintf (stderr, " (S/390)");
-
extern int flag_pic;
/* Run-time compilation parameters selecting different hardware subsets. */
--- 22,27 ----
*************** extern int target_flags;
*** 33,46 ****
/* Target macros checked at runtime of compiler. */
#define TARGET_HARD_FLOAT (target_flags & 1)
#define TARGET_BACKCHAIN (target_flags & 2)
#define TARGET_SMALL_EXEC (target_flags & 4)
#define TARGET_DEBUG_ARG (target_flags & 8)
#define TARGET_64BIT (target_flags & 16)
#define TARGET_MVCLE (target_flags & 32)
#define TARGET_DEFAULT 0x3
! #define TARGET_SOFT_FLOAT (!(target_flags & 1))
/* Macro to define tables used to set the flags. This is a list in braces
of pairs in braces, each pair being { "NAME", VALUE }
--- 31,51 ----
/* Target macros checked at runtime of compiler. */
#define TARGET_HARD_FLOAT (target_flags & 1)
+ #define TARGET_SOFT_FLOAT (!(target_flags & 1))
#define TARGET_BACKCHAIN (target_flags & 2)
#define TARGET_SMALL_EXEC (target_flags & 4)
#define TARGET_DEBUG_ARG (target_flags & 8)
#define TARGET_64BIT (target_flags & 16)
#define TARGET_MVCLE (target_flags & 32)
+ #ifdef DEFAULT_TARGET_64BIT
+ #define TARGET_DEFAULT 0x13
+ #define TARGET_VERSION fprintf (stderr, " (zSeries)");
+ #else
#define TARGET_DEFAULT 0x3
! #define TARGET_VERSION fprintf (stderr, " (S/390)");
! #endif
!
/* Macro to define tables used to set the flags. This is a list in braces
of pairs in braces, each pair being { "NAME", VALUE }
*************** extern enum reg_class regclass_map[FIRST
*** 640,646 ****
/* We have 31 bit mode. */
! #define MASK_RETURN_ADDR (GEN_INT (0x7fffffff))
/* The offset from the incoming value of %sp to the top of the stack frame
for the current function. */
--- 645,651 ----
/* We have 31 bit mode. */
! #define MASK_RETURN_ADDR (TARGET_64BIT ? GEN_INT (-1) : GEN_INT (0x7fffffff))
/* The offset from the incoming value of %sp to the top of the stack frame
for the current function. */
Index: gcc/config/s390/s390x.h
===================================================================
RCS file: s390x.h
diff -N s390x.h
*** /dev/null Tue May 5 13:32:27 1998
--- s390x.h Wed Feb 6 12:29:31 2002
***************
*** 0 ****
--- 1,27 ----
+ /* Definitions of target machine for IBM zSeries 64-bit
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Hartmut Penner (hpenner@de.ibm.com) and
+ Ulrich Weigand (uweigand@de.ibm.com).
+ This file is part of GNU CC.
+
+ GNU CC 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 2, or (at your option)
+ any later version.
+
+ GNU CC 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 GNU CC; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ #ifndef _S390X_H
+ #define _S390X_H
+
+ #define DEFAULT_TARGET_64BIT
+
+ #endif
More information about the Gcc-patches
mailing list