-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile.uk
211 lines (185 loc) · 8.72 KB
/
Makefile.uk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# SPDX-License-Identifier: BSD-3-Clause
#
# libgo Makefile.uk
#
# Authors: Charalampos Mainas <charalampos.mainas@neclab.eu>
# Costin Lupu <costin.lupu@cs.pub.ro>
# Marc Rittinghaus <marc.rittinghaus@kit.edu>
#
# Copyright (c) 2019, NEC Europe Ltd., NEC Corporation
# 2019, University Politehnica of Bucharest
# 2022, Karlsruhe Institute of Technology (KIT)
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
################################################################################
# Library registration
################################################################################
$(eval $(call addlib_s,libgo,$(CONFIG_LIBGO)))
$(eval $(call addlib_s,libgoffi,$(CONFIG_LIBGO)))
$(eval $(call addlib_s,libgobacktrace,$(CONFIG_LIBGO)))
################################################################################
# Original sources
################################################################################
LIBGCC_VERSION=12.1.0
LIBGCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(LIBGCC_VERSION)/gcc-$(LIBGCC_VERSION).tar.gz
LIBGO_PATCHDIR=$(LIBGO_BASE)/patches
LIBGCC_SUBDIR=gcc-$(LIBGCC_VERSION)
ifeq ($(call have_gcc),y)
$(call error_if_gcc_version_lt,12,1)
endif
$(eval $(call fetch,libgo,$(LIBGCC_URL)))
$(eval $(call patch,libgo,$(LIBGO_PATCHDIR),$(LIBGCC_SUBDIR)))
################################################################################
# Helpers
################################################################################
LIBGCC_EXTRACTED = $(LIBGO_ORIGIN)/gcc-$(LIBGCC_VERSION)
LIBGO_EXTRACTED = $(LIBGCC_EXTRACTED)/libgo
LIBGOFFI_EXTRACTED = $(LIBGCC_EXTRACTED)/libffi
LIBGOBACKTRACE_EXTRACTED = $(LIBGCC_EXTRACTED)/libbacktrace
################################################################################
# Library includes
################################################################################
LIBGO_COMMON_INCLUDES-y += -I$(LIBGO_BASE)/libgo/include
LIBGO_COMMON_INCLUDES-y += -I$(LIBGCC_EXTRACTED)/include
LIBGO_COMMON_INCLUDES-y += -I$(LIBGCC_EXTRACTED)/libgcc
LIBGO_COMMON_INCLUDES-y += -I$(LIBGCC_EXTRACTED)/gcc
LIBGO_COMMON_INCLUDES-y += -I$(LIBGCC_EXTRACTED)/gcc/include
LIBGO_COMMON_INCLUDES-$(CONFIG_ARCH_X86_64) += -I$(LIBGCC_EXTRACTED)/gcc/config/i386
LIBGO_COMMON_INCLUDES-$(CONFIG_ARCH_ARM_64) += -I$(LIBGCC_EXTRACTED)/gcc/config/aarch64
LIBGO_INCLUDES-y += -I$(LIBGO_BASE)
LIBGO_INCLUDES-y += -I$(LIBGO_EXTRACTED)
LIBGO_INCLUDES-y += -I$(LIBGO_EXTRACTED)/runtime
LIBGOFFI_INCLUDES-$(CONFIG_ARCH_X86_64) += -I$(LIBGO_BASE)/libffi/include/x86
LIBGOFFI_INCLUDES-$(CONFIG_ARCH_ARM_64) += -I$(LIBGO_BASE)/libffi/include/arm64
LIBGOFFI_INCLUDES-y += -I$(LIBGCC_EXTRACTED)/libffi/include
LIBGOFFI_INCLUDES-$(CONFIG_ARCH_X86_64) += -I$(LIBGCC_EXTRACTED)/libffi/src/x86
LIBGOFFI_INCLUDES-$(CONFIG_ARCH_ARM_64) += -I$(LIBGCC_EXTRACTED)/libffi/src/arm64
LIBGOBACKTRACE_INCLUDES-y += -I$(LIBGO_BASE)/libbacktrace/include
LIBGOBACKTRACE_INCLUDES-y += -I$(LIBGCC_EXTRACTED)/libbacktrace
# libgo
LIBGO_ASINCLUDES-y += $(LIBGO_COMMON_INCLUDES-y)
LIBGO_ASINCLUDES-y += $(LIBGO_INCLUDES-y)
LIBGO_ASINCLUDES-y += $(LIBGOFFI_INCLUDES-y)
LIBGO_ASINCLUDES-y += $(LIBGOBACKTRACE_INCLUDES-y)
LIBGO_CINCLUDES-y += $(LIBGO_COMMON_INCLUDES-y)
LIBGO_CINCLUDES-y += $(LIBGO_INCLUDES-y)
LIBGO_CINCLUDES-y += $(LIBGOFFI_INCLUDES-y)
LIBGO_CINCLUDES-y += $(LIBGOBACKTRACE_INCLUDES-y)
# libffi
LIBGOFFI_ASINCLUDES-y += $(LIBGO_COMMON_INCLUDES-y)
LIBGOFFI_ASINCLUDES-y += $(LIBGOFFI_INCLUDES-y)
LIBGOFFI_CINCLUDES-y += $(LIBGO_COMMON_INCLUDES-y)
LIBGOFFI_CINCLUDES-y += $(LIBGOFFI_INCLUDES-y)
# libbacktrace
LIBGOBACKTRACE_ASINCLUDES-y += $(LIBGO_COMMON_INCLUDES-y)
LIBGOBACKTRACE_ASINCLUDES-y += $(LIBGOBACKTRACE_INCLUDES-y)
LIBGOBACKTRACE_CINCLUDES-y += $(LIBGO_COMMON_INCLUDES-y)
LIBGOBACKTRACE_CINCLUDES-y += $(LIBGOBACKTRACE_INCLUDES-y)
################################################################################
# Global flags
################################################################################
# libgo
LIBGO_CFLAGS-y += -fno-checking
LIBGO_CFLAGS-y += -DHAVE_CONFIG_H
LIBGO_CFLAGS-y += -fexceptions
LIBGO_CFLAGS-y += -fnon-call-exceptions
LIBGO_CFLAGS-y += -fno-split-stack
LIBGO_CFLAGS-y += -Wall
LIBGO_CFLAGS-y += -Wextra
LIBGO_CFLAGS-y += -Wwrite-strings
LIBGO_CFLAGS-y += -Werror
LIBGO_CFLAGS-y += -Wno-error=missing-braces
LIBGO_CFLAGS-y += -Wno-missing-braces
LIBGO_CFLAGS-y += -Wno-error=sign-compare
LIBGO_CFLAGS-y += -Wno-sign-compare
LIBGO_CFLAGS-y += -D_GNU_SOURCE
LIBGO_CFLAGS-y += -D_LARGEFILE_SOURCE
LIBGO_CFLAGS-y += -D_FILE_OFFSET_BITS=64
LIBGO_CFLAGS-y += -D__linux__
LIBGO_CFLAGS-$(CONFIG_ARCH_X86_64) += -minline-all-stringops
LIBGO_CFLAGS-$(CONFIG_ARCH_X86_64) += -D__x86_64__
LIBGO_CFLAGS-$(CONFIG_ARCH_ARM_64) += -D__ARM_64__
LIBGO_ASFLAGS-y += -D__linux__
LIBGO_ASFLAGS-$(CONFIG_ARCH_X86_64) += -D__x86_64__
LIBGO_ASFLAGS-$(CONFIG_ARCH_ARM_64) += -D__ARM_64__
ifeq ($(CONFIG_LIBGO), y)
GOFLAGS-$(CONFIG_ARCH_X86_64) += -minline-all-stringops
GOFLAGS-y += -Wno-return-local-addr
GOFLAGS-y += -Wno-maybe-uninitialized
GOFLAGS-y += -Wno-uninitialized
endif
# libffi
LIBGOFFI_CFLAGS-y += -DHAVE_CONFIG_H
LIBGOFFI_CFLAGS-y += -fno-checking
LIBGOFFI_CFLAGS-$(CONFIG_ARCH_X86_64) += -D__x86_64__
LIBGOFFI_CFLAGS-y += -Wno-unused-parameter
LIBGOFFI_CFLAGS-y += -Wno-unused-label
LIBGOFFI_CFLAGS-y += -Wno-sign-compare
LIBGOFFI_CFLAGS-y += -Wno-deprecated-declarations
LIBGOFFI_CFLAGS-y += -Wno-implicit-fallthrough
LIBGOFFI_CFLAGS-y += -Wno-empty-body
# libbacktrace
LIBGOBACKTRACE_CFLAGS-y +=
################################################################################
# libgo code
################################################################################
LIBGO_SRCS-y += $(LIBGO_BASE)/stubs.c
# libgo
LIBGO_SRCS-y += $(LIBGO_EXTRACTED)/runtime/go-main.c
include $(LIBGO_BASE)/libgo/Makefile.native.uk
include $(LIBGO_BASE)/libgo/Makefile.runtime.uk
# libffi
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/types.c
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/closures.c
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/java_raw_api.c
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/raw_api.c
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/tramp.c
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/prep_cif.c
ifeq (x86_64,$(CONFIG_UK_ARCH))
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/x86/ffi64.c
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/x86/unix64.S
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/x86/win64.S
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/x86/ffiw64.c
else
ifeq (arm64,$(CONFIG_UK_ARCH))
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/aarch64/ffi.c
LIBGOFFI_SRCS-y += $(LIBGOFFI_EXTRACTED)/src/aarch64/sysv.S
endif
endif
# libbacktrace
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/atomic.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/backtrace.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/dwarf.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/elf.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/fileline.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/mmap.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/mmapio.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/posix.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/print.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/simple.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/sort.c
LIBGOBACKTRACE_SRCS-y += $(LIBGOBACKTRACE_EXTRACTED)/state.c