forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshared
244 lines (219 loc) · 8.97 KB
/
shared
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
%_cross_vendor bottlerocket
%_cross_libc gnu
%_cross_os %{_cross_vendor}-%{_cross_arch}-
%_cross_triple %{_cross_arch}-%{_cross_vendor}-linux
%_cross_target %{_cross_triple}-%{_cross_libc}
%dist %{nil}
%_cross_cflags %{shrink: \
-O2 -g -pipe -Wall \
-Werror=format-security -Werror=strict-aliasing \
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS \
-fexceptions -fstack-clash-protection -fno-semantic-interposition \
%{nil}}
%_cross_c_args %{shrink: \
'-O2', '-g', '-pipe', '-Wall', \
'-Werror=format-security', '-Werror=strict-aliasing', \
'-Wp,-D_FORTIFY_SOURCE=2', '-Wp,-D_GLIBCXX_ASSERTIONS', \
'-fexceptions', '-fstack-clash-protection', '-fno-semantic-interposition' \
%{nil}}
%_cross_cxxflags %_cross_cflags
%_cross_ldflags -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions
%_cross_c_link_args '-Wl,-z,relro', '-Wl,-z,now', '-Wl,-Bsymbolic-functions'
%_cross_lib lib
%_cross_rootdir /%{_cross_target}/sys-root
%_cross_prefix %{_cross_rootdir}%{_prefix}
%_cross_exec_prefix %{_cross_rootdir}%{_exec_prefix}
%_cross_bindir %{_cross_rootdir}%{_bindir}
%_cross_sbindir %{_cross_rootdir}%{_sbindir}
%_cross_libdir %{_cross_prefix}/%{_cross_lib}
%_cross_libexecdir %{_cross_rootdir}%{_libexecdir}
%_cross_includedir %{_cross_rootdir}%{_includedir}
%_cross_sysconfdir %{_sysconfdir}
%_cross_tmpfilesdir %{_cross_rootdir}%{_tmpfilesdir}
%_cross_datadir %{_cross_rootdir}%{_datadir}
%_cross_datarootdir %{_cross_rootdir}%{_datarootdir}
%_cross_docdir %{_cross_datarootdir}/doc
%_cross_factorydir %{_cross_datarootdir}/factory
%_cross_localedir %{_cross_datarootdir}/locale
%_cross_infodir %{_cross_rootdir}%{_infodir}
%_cross_mandir %{_cross_rootdir}%{_mandir}
%_cross_rundir %{_rundir}
%_cross_sharedstatedir %{_sharedstatedir}
%_cross_localstatedir %{_localstatedir}
%_cross_bashdir %{_cross_datadir}/bash-completion
%_cross_pkgconfigdir %{_cross_libdir}/pkgconfig
%_cross_unitdir %{_cross_rootdir}%{_unitdir}
%_cross_userunitdir %{_cross_rootdir}%{_userunitdir}
%_cross_journalcatalogdir %{_cross_rootdir}%{_journalcatalogdir}
%_cross_systemdgeneratordir %{_cross_rootdir}%{_systemdgeneratordir}
%_cross_systemdusergeneratordir %{_cross_rootdir}%{_systemdusergeneratordir}
%_cross_sysusersdir %{_cross_rootdir}%{_sysusersdir}
%_cross_sysctldir %{_cross_rootdir}%{_sysctldir}
%_cross_templatedir %{_cross_datadir}/templates
%_cross_usrsrc %{_cross_prefix}/src
%_cross_udevrulesdir %{_cross_rootdir}%{_udevrulesdir}
%_cross_licensedir %{_cross_datadir}/licenses
%_defaultlicensedir %{_cross_licensedir}
%_uncross_name %(name=%{name}; echo ${name#%{_cross_os}})
%_docdir_fmt %{_uncross_name}
%set_cross_build_flags \
CFLAGS="${CFLAGS:-%{_cross_cflags}}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%{_cross_cxxflags}}" ; export CXXFLAGS ; \
LDFLAGS="${LDFLAGS:-%{_cross_ldflags}}" ; export LDFLAGS ; \
PKG_CONFIG_PATH="%{_cross_pkgconfigdir}" ; export PKG_CONFIG_PATH ; \
PKG_CONFIG_ALLOW_CROSS=1 ; export PKG_CONFIG_ALLOW_CROSS ; \
%cross_configure \
%set_cross_build_flags \
ac_cv_func_malloc_0_nonnull=yes \\\
ac_cv_func_realloc_0_nonnull=yes \\\
%{_configure} \\\
--host=%{_cross_target} \\\
--target=%{_cross_target} \\\
--build=%{_build} \\\
--disable-dependency-tracking \\\
--prefix=%{_cross_prefix} \\\
--exec-prefix=%{_cross_exec_prefix} \\\
--bindir=%{_cross_bindir} \\\
--sbindir=%{_cross_sbindir} \\\
--sysconfdir=%{_cross_sysconfdir} \\\
--datadir=%{_cross_datadir} \\\
--includedir=%{_cross_includedir} \\\
--libdir=%{_cross_libdir} \\\
--libexecdir=%{_cross_libexecdir} \\\
--localstatedir=%{_cross_localstatedir} \\\
--sharedstatedir=%{_cross_sharedstatedir} \\\
--mandir=%{_cross_mandir} \\\
--infodir=%{_cross_infodir}
%_cross_vpath_srcdir .
%_cross_vpath_builddir %_cross_target
%_cross_compilation_conf %{_cross_vpath_srcdir}/cross-compilation.conf
%write_cross_compilation_conf \
cat <<CROSS_COMPILATION_CONF_EOF >%_cross_compilation_conf 2>/dev/null || :\
[binaries]\
c = '%{_cross_target}-gcc'\
cpp = '%{_cross_target}-g++'\
ar = '%{_cross_target}-ar'\
strip = '%{_cross_target}-strip'\
pkgconfig = '/usr/bin/pkg-config'\
[built-in options]\
c_args = [%{_cross_c_args}]\
c_link_args = [%{_cross_c_link_args}]\
[properties]\
pkg_config_libdir = '%{_cross_pkgconfigdir}'\
needs_exe_wrapper = true\
[host_machine]\
system = 'linux'\
cpu_family ='%{_cross_cpu_family}'\
cpu = '%{_cross_arch}'\
endian = '%{_cross_endian}'\
CROSS_COMPILATION_CONF_EOF\
%{nil}
%cross_meson \
%write_cross_compilation_conf \
%set_cross_build_flags \
%{shrink:%{__meson} \
--buildtype=plain \
--default-library=shared \
--cross-file=%{_cross_compilation_conf} \
--prefix=%{_cross_prefix} \
--libdir=%{_cross_libdir} \
--libexecdir=%{_cross_libexecdir} \
--bindir=%{_cross_bindir} \
--sbindir=%{_cross_sbindir} \
--includedir=%{_cross_includedir} \
--datadir=%{_cross_datadir} \
--mandir=%{_cross_mandir} \
--infodir=%{_cross_infodir} \
--localedir=%{_cross_localedir} \
--sysconfdir=%{_cross_sysconfdir} \
--localstatedir=%{_cross_localstatedir} \
--sharedstatedir=%{_cross_sharedstatedir} \
--wrap-mode=%{__meson_wrap_mode} \
--auto-features=%{__meson_auto_features} \
%{_cross_vpath_srcdir} %{_cross_vpath_builddir} \
%{nil}}
%cross_meson_build \
%ninja_build -C %{_cross_vpath_builddir}
%cross_meson_install \
%ninja_install -C %{_cross_vpath_builddir}
%cross_cmake \
%set_cross_build_flags \
%{shrink:%{__cmake} \
-DCMAKE_C_SYSTEM_NAME:STRING="Linux" \
-DCMAKE_C_COMPILER:STRING="%{_cross_target}-gcc" \
-DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \
-DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH=%{_cross_prefix} \
-DINCLUDE_INSTALL_DIR:PATH=%{_cross_includedir} \
-DLIB_INSTALL_DIR:PATH=%{_cross_libdir} \
-DSYSCONF_INSTALL_DIR:PATH=%{_cross_sysconfdir} \
-DSHARE_INSTALL_PREFIX:PATH=%{_cross_datadir} \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_SKIP_RPATH:BOOL=ON \
%{nil}}
%_cross_go_os linux
%set_cross_go_flags \
GOPATH="${PWD}/GOPATH" ; export GOPATH ; \
GOOS="%{_cross_go_os}" ; export GOOS ; \
GOARCH="%{_cross_go_arch}" ; export GOARCH ; \
CC="%{_cross_target}-gcc" ; export CC ; \
CC_FOR_TARGET="%{_cross_target}-gcc" ; export CC_FOR_TARGET ; \
CC_FOR_%{_cross_go_os}_%{_cross_go_arch}="%{_cross_target}-gcc" ; export CC_FOR_%{_cross_go_os}_%{_cross_go_arch} ; \
CXX="%{_cross_target}-g++" ; export CXX ; \
CXX_FOR_TARGET="%{_cross_target}-g++" ; export CXX_FOR_TARGET ; \
CXX_FOR_%{_cross_go_os}_%{_cross_go_arch}="%{_cross_target}-g++" ; export CXX_FOR_%{_cross_go_os}_%{_cross_go_arch} ; \
CGO_ENABLED=1 ; export CGO_ENABLED ; \
CGO_CFLAGS="%{_cross_cflags}" ; export CGO_CFLAGS ; \
CGO_CXXFLAGS="%{_cross_cxxflags}" ; export CGO_CXXFLAGS ; \
CGO_LDFLAGS="%{_cross_ldflags}" ; export CGO_LDFLAGS ; \
PKG_CONFIG_PATH="%{_cross_pkgconfigdir}" ; export PKG_CONFIG_PATH ; \
PKG_CONFIG_ALLOW_CROSS=1 ; export PKG_CONFIG_ALLOW_CROSS ; \
GOFLAGS="-mod=vendor"; export GOFLAGS ; \
GOLDFLAGS="-compressdwarf=false -linkmode=external" ; export GOLDFLAGS ; \
GOPROXY="off"; export GOPROXY ; \
GOSUMDB="off"; export GOSUMDB ; \
GO111MODULE="auto"; export GO111MODULE ; \
%cross_go_setup() \
mkdir -p GOPATH/src/%2 ; \
ln -s %{_builddir}/%1 GOPATH/src/%3 ; \
%cross_go_configure() \
%set_cross_go_flags \
cd GOPATH/src/%1 ; \
%_cross_attribution_file %{_cross_licensedir}/%{_uncross_name}/attribution.txt
%cross_generate_attribution \
if [ 0%{?_cross_first_party} -eq 0 ]; then \
mkdir -p %{buildroot}%{_cross_licensedir}/%{_uncross_name} \
echo "%{name} - %{url}" >> %{buildroot}%{_cross_attribution_file} \
echo "SPDX-License-Identifier: %{license}" >> %{buildroot}%{_cross_attribution_file} \
fi
%_cross_attribution_vendor_dir %{_cross_licensedir}/%{_uncross_name}/vendor
%cross_scan_attribution \
bottlerocket-license-scan --spdx-data /usr/libexec/tools/spdx-data --out-dir %{buildroot}%{_cross_attribution_vendor_dir}
%__nm %{_bindir}/%{_cross_target}-nm
%__objcopy %{_bindir}/%{_cross_target}-objcopy
%__objdump %{_bindir}/%{_cross_target}-objdump
%__strip %{_bindir}/%{_cross_target}-strip
# Prevent RPM from erroring out the build when it detects our cross-compiled
# artifacts.
%_binaries_in_noarch_packages_terminate_build 0
# Prevent RPM from detecting provides or requires for any files.
%__requires_exclude ^.*$
%__provides_exclude ^.*$
# Do not generate build ID links in main packages.
%_build_id_links alldebug
# Do not run ldconfig after build.
%__brp_ldconfig %{nil}
# Disable mangling since we do not have interpreters, and this causes build
# failures when rewriting "shebangs" in crate files.
%__brp_mangle_shebangs /bin/true
# Do not compress debuginfo.
%_find_debuginfo_dwz_opts %{nil}
# Compress RPM payloads with zstd level 1 in single-threaded mode.
%_source_payload w1.zstdio
%_binary_payload w1.zstdio
%__arch_install_post \
/usr/lib/rpm/check-buildroot \
%cross_generate_attribution
%source_date_epoch_from_changelog 0