Skip to content

Commit 17f98c1

Browse files
dcpleunggalak
authored andcommitted
x86_64: adds config to build toolchain for x86_64
This adds the config to build x86_64 toolchain with tuple x86_64-zephyr-elf. This allows decoupling the builds from the host toolchain. Signed-off-by: Daniel Leung <[email protected]>
1 parent 578b909 commit 17f98c1

File tree

6 files changed

+809
-0
lines changed

6 files changed

+809
-0
lines changed

.shippable.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ env:
1414
- TARGET=mips
1515
- TARGET=arc
1616
- TARGET=xtensa
17+
- TARGET=x86_64-zephyr-elf
1718
- TARGET="tools"
1819

1920
build:

configs/x86_64-zephyr-elf.config

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CT_CONFIG_VERSION="2"
2+
CT_LOCAL_TARBALLS_DIR="${CT_PREFIX:-${HOME}/x-tools}/sources"
3+
# CT_PREFIX_DIR_RO is not set
4+
CT_PATCH_BUNDLED_LOCAL=y
5+
CT_LOCAL_PATCH_DIR="${CT_TOP_DIR}/../../patches"
6+
# CT_LOG_PROGRESS_BAR is not set
7+
CT_ARCH_X86=y
8+
CT_MULTILIB=y
9+
CT_ARCH_64=y
10+
CT_TARGET_VENDOR="zephyr"
11+
CT_LIBC_NEWLIB_TARGET_CFLAGS="-DMISSING_SYSCALL_NAMES"
12+
CT_LIBC_NEWLIB_IO_FLOAT=y
13+
# CT_LIBC_NEWLIB_FSEEK_OPTIMIZATION is not set
14+
CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS=y
15+
CT_LIBC_NEWLIB_GLOBAL_ATEXIT=y
16+
CT_LIBC_NEWLIB_LITE_EXIT=y
17+
# CT_LIBC_NEWLIB_MULTITHREAD is not set
18+
# CT_LIBC_NEWLIB_WIDE_ORIENT is not set
19+
CT_LIBC_NEWLIB_NANO_MALLOC=y
20+
CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y
21+
CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array"
22+
CT_CC_GCC_MULTILIB_LIST="m64,m32,mx32"
23+
CT_CC_LANG_CXX=y
24+
CT_DEBUG_GDB=y
25+
CT_ISL_V_0_18=y
26+
CT_LIBICONV_NEEDED=y
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
From 3d87485df3be0a7c31890d34febd7a7db0987054 Mon Sep 17 00:00:00 2001
2+
From: Kumar Gala <[email protected]>
3+
Date: Mon, 6 May 2019 15:55:48 -0500
4+
Subject: [PATCH 1/1] Add support to build for x86_64-zephyr-elf
5+
6+
This adds the necessary bits to build for x86_64-zephyr-elf with
7+
multilib support (m32, mx32 and m64), following the x86_64-*-linux*
8+
footsteps.
9+
10+
Signed-off-by: Kumar Gala <[email protected]>
11+
Signed-off-by: Daniel Leung <[email protected]>
12+
---
13+
configure | 2 +-
14+
gcc/acinclude.m4 | 12 ++++++++++
15+
gcc/config.gcc | 27 +++++++++++++++++++++++
16+
gcc/config/i386/t-zephyr64 | 38 ++++++++++++++++++++++++++++++++
17+
gcc/configure | 9 ++++++++
18+
libgcc/config.host | 7 +++++-
19+
libgcc/config/i386/64/t-zephyr64 | 1 +
20+
7 files changed, 94 insertions(+), 2 deletions(-)
21+
create mode 100644 gcc/config/i386/t-zephyr64
22+
create mode 100644 libgcc/config/i386/64/t-zephyr64
23+
24+
diff --git a/configure b/configure
25+
index 060139551..faf81543c 100755
26+
--- a/configure
27+
+++ b/configure
28+
@@ -7465,7 +7465,7 @@ fi
29+
# Special user-friendly check for native x86_64-linux build, if
30+
# multilib is not explicitly enabled.
31+
case "$target:$have_compiler:$host:$target:$enable_multilib" in
32+
- x86_64-*linux*:yes:$build:$build:)
33+
+ x86_64-*linux*:yes:$build:$build: | x86_64-zephyr-elf:yes:$build:$build:)
34+
# Make sure we have a development environment that handles 32-bit
35+
dev64=no
36+
echo "int main () { return 0; }" > conftest.c
37+
diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
38+
index 950a2d4de..edd3c6b78 100644
39+
--- a/gcc/acinclude.m4
40+
+++ b/gcc/acinclude.m4
41+
@@ -507,6 +507,18 @@ AC_DEFUN([gcc_GAS_FLAGS],
42+
dnl Override the default, which may be incompatible.
43+
gcc_cv_as_flags=--64
44+
;;
45+
+ i[[34567]]86-zephyr*)
46+
+ dnl Override the default, which may be incompatible.
47+
+ gcc_cv_as_flags=--32
48+
+ ;;
49+
+ x86_64-zephyr-elfx32)
50+
+ dnl Override the default, which may be incompatible.
51+
+ gcc_cv_as_flags=--x32
52+
+ ;;
53+
+ x86_64-zephyr*)
54+
+ dnl Override the default, which may be incompatible.
55+
+ gcc_cv_as_flags=--64
56+
+ ;;
57+
powerpc*-*-darwin*)
58+
dnl Always pass -arch ppc to assembler.
59+
gcc_cv_as_flags="-arch ppc"
60+
diff --git a/gcc/config.gcc b/gcc/config.gcc
61+
index 446e07ff6..8729dad0b 100644
62+
--- a/gcc/config.gcc
63+
+++ b/gcc/config.gcc
64+
@@ -1500,6 +1500,33 @@ i586-zephyr-elf)
65+
i[34567]86-*-elf*)
66+
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h"
67+
;;
68+
+x86_64-zephyr-elf*)
69+
+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
70+
+ tmake_file="${tmake_file} i386/t-zephyr64"
71+
+ x86_multilibs="${with_multilib_list}"
72+
+ if test "$x86_multilibs" = "default"; then
73+
+ case ${with_abi} in
74+
+ x32 | mx32)
75+
+ x86_multilibs="mx32"
76+
+ ;;
77+
+ *)
78+
+ x86_multilibs="m64,m32"
79+
+ ;;
80+
+ esac
81+
+ fi
82+
+ x86_multilibs=`echo $x86_multilibs | sed -e 's/,/ /g'`
83+
+ for x86_multilib in ${x86_multilibs}; do
84+
+ case ${x86_multilib} in
85+
+ m32 | m64 | mx32)
86+
+ TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG},${x86_multilib}"
87+
+ ;;
88+
+ *)
89+
+ echo "--with-multilib-list=${x86_with_multilib} not supported."
90+
+ exit 1
91+
+ esac
92+
+ done
93+
+ TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
94+
+ ;;
95+
x86_64-*-elf*)
96+
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
97+
;;
98+
diff --git a/gcc/config/i386/t-zephyr64 b/gcc/config/i386/t-zephyr64
99+
new file mode 100644
100+
index 000000000..a47de2902
101+
--- /dev/null
102+
+++ b/gcc/config/i386/t-zephyr64
103+
@@ -0,0 +1,38 @@
104+
+# Copyright (C) 2002-2018 Free Software Foundation, Inc.
105+
+#
106+
+# This file is part of GCC.
107+
+#
108+
+# GCC is free software; you can redistribute it and/or modify
109+
+# it under the terms of the GNU General Public License as published by
110+
+# the Free Software Foundation; either version 3, or (at your option)
111+
+# any later version.
112+
+#
113+
+# GCC is distributed in the hope that it will be useful,
114+
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
115+
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
116+
+# GNU General Public License for more details.
117+
+#
118+
+# You should have received a copy of the GNU General Public License
119+
+# along with GCC; see the file COPYING3. If not see
120+
+# <http://www.gnu.org/licenses/>.
121+
+
122+
+# On Debian, Ubuntu and other derivative distributions, the 32bit libraries
123+
+# are found in /lib32 and /usr/lib32, /lib64 and /usr/lib64 are symlinks to
124+
+# /lib and /usr/lib, while other distributions install libraries into /lib64
125+
+# and /usr/lib64. The LSB does not enforce the use of /lib64 and /usr/lib64,
126+
+# it doesn't tell anything about the 32bit libraries on those systems. Set
127+
+# MULTILIB_OSDIRNAMES according to what is found on the target.
128+
+
129+
+# To support i386, x86-64 and x32 libraries, the directory structrue
130+
+# should be:
131+
+#
132+
+# /lib has i386 libraries.
133+
+# /lib64 has x86-64 libraries.
134+
+# /libx32 has x32 libraries.
135+
+#
136+
+comma=,
137+
+MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
138+
+MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
139+
+MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-zephyr-elf)
140+
+MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-zephyr-elf)
141+
+MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-zephyr-elfx32)
142+
diff --git a/gcc/configure b/gcc/configure
143+
index 6121e1632..de654f537 100755
144+
--- a/gcc/configure
145+
+++ b/gcc/configure
146+
@@ -22410,6 +22410,15 @@ else
147+
x86_64-*-linux*)
148+
gcc_cv_as_flags=--64
149+
;;
150+
+ i[34567]86-zephyr*)
151+
+ gcc_cv_as_flags=--32
152+
+ ;;
153+
+ x86_64-zephyr-elfx32)
154+
+ gcc_cv_as_flags=--x32
155+
+ ;;
156+
+ x86_64-zephyr*)
157+
+ gcc_cv_as_flags=--64
158+
+ ;;
159+
powerpc*-*-darwin*)
160+
gcc_cv_as_flags="-arch ppc"
161+
;;
162+
diff --git a/libgcc/config.host b/libgcc/config.host
163+
index fbc79366d..603464b06 100644
164+
--- a/libgcc/config.host
165+
+++ b/libgcc/config.host
166+
@@ -612,6 +612,11 @@ i586-zephyr-elf)
167+
i[34567]86-*-elf*)
168+
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
169+
;;
170+
+x86_64-zephyr-elf)
171+
+ tmake_file="$tmake_file i386/t-crtstuff i386/64/t-zephyr64 t-dfprules"
172+
+ tm_file="${tm_file} i386/elf-lib.h"
173+
+ md_unwind_header=i386/linux-unwind.h
174+
+ ;;
175+
x86_64-*-elf* | x86_64-*-rtems*)
176+
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
177+
;;
178+
@@ -1406,7 +1411,7 @@ i[34567]86-*-* | x86_64-*-*)
179+
esac
180+
181+
case ${host} in
182+
-i[34567]86-*-linux* | x86_64-*-linux*)
183+
+i[34567]86-*-linux* | x86_64-*-linux* | x86_64-zephyr-elf)
184+
# Provide backward binary compatibility for 64bit Linux/x86.
185+
if test "${host_address}" = 64; then
186+
tmake_file="${tmake_file} i386/${host_address}/t-softfp-compat"
187+
diff --git a/libgcc/config/i386/64/t-zephyr64 b/libgcc/config/i386/64/t-zephyr64
188+
new file mode 100644
189+
index 000000000..7595cdeed
190+
--- /dev/null
191+
+++ b/libgcc/config/i386/64/t-zephyr64
192+
@@ -0,0 +1 @@
193+
+HOST_LIBGCC2_CFLAGS += -mlong-double-80
194+
--
195+
2.21.0
196+

0 commit comments

Comments
 (0)