summaryrefslogtreecommitdiff
path: root/packaging/binutils-aarch64.spec
blob: 6006d7ad86ffdd8d52153c447eaf692796c1a70e (plain)
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
%define cross aarch64
%define aarch64 1

%ifarch armv7l
%define ARCH armv7l
%define ABI eabi
%endif
%ifarch armv7hl
%define ARCH armv7hl
%define ABI eabihf
%endif
%ifarch %ix86
%define ARCH i586
%endif
%ifarch x86_64
%define ARCH x86_64
%endif
%ifarch aarch64
%define ARCH aarch64
%endif

%define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}

%define target_cpu %{?cross}%{!?cross:%{ARCH}}
%define target_abi %{?cross:%{?armv7l:eabi}%{?armv7hl:eabihf}}%{!?cross:%{?ABI}}

%define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}

%if 0%{?run_tests}
%{!?cross:
%define binutils_run_tests 1
}
%endif

%if 0%{?dump_configure}
%define binutils_dump_configure 1
%endif

# Enable this when testing on device to:
# 1. Enable macro to turn on testsuite building ('binutils_run_tests 1')
# 2. Keep 'build-dir/' folder in build stage as we do not want to rebuild all
# binutils again on device after invoking rpmbuild --short-circuit -bc ...
# 3. Skip configure and make commands and go directly to 'make check'
%if 0%{?run_tests_on_device}
%define binutils_run_tests 1
%define binutils_keep_build_dir 1
%define binutils_skip_configure 1
%define binutils_skip_make 1
%endif

# Exit right after 'make ..' step to keep all object files produced by binutils build
%if 0%{?exit_on_make_finish}
%define binutils_exit_on_make_finish 1
%endif

Name:           binutils%{?cross:-%{cross}}
BuildRequires:  makeinfo
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  ncurses-devel
BuildRequires:  zlib-devel
BuildRequires:  gcc-c++
%if 0%{?binutils_run_tests}
BuildRequires:  dejagnu
BuildRequires:  glibc-devel-static
%endif
%if 0%{?binutils_dump_configure}
BuildRequires: configure-dumper
%endif
Version:        2.33.1
Release:        0
Url:            http://www.gnu.org/software/binutils/
Summary:        GNU Binutils
License:        GFDL-1.3 and GPL-3.0+
Group:          Development/Building
%{?cross:ExcludeArch: %{cross}}
Source:         binutils-%{version}.tar.bz2
Source1001:     binutils.manifest

%description
C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
size, strings, and strip. These utilities are needed whenever you want
to compile a program or kernel.


%package gold
Summary:        The gold linker
License:        GPL-3.0+
Group:          Development/Building

%description gold
gold is an ELF linker.	It is intended to have complete support for ELF
and to run as fast as possible on modern systems.  For normal use it is
a drop-in replacement for the older GNU linker.


%package devel
Summary:        GNU binutils (BFD development files)
License:        GPL-3.0+
Group:          Development/Building
Requires: zlib-devel

%description devel
This package includes header files and static libraries necessary to
build programs which use the GNU BFD library, which is part of
binutils.

%{?binutils_run_tests:
%package testresults
Summary:       Testsuite results
License:       Public Domain
Group:         Development/Building
%description testresults
Results from running the binutils tests.
}

%{?binutils_dump_configure:
%package configure-dump
Summary:       GNU Binutils configure dump
License:       GPL-3.0+
Group:         Development/Languages
%description configure-dump
This package contains dump of configure variables of Binutils
}

%prep
%setup -q -n binutils-%{version}
cp %{SOURCE1001} .


%build
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error %{?cross:-DIGNORE_BROKEN_PLUGINS}"
export CFLAGS="${RPM_OPT_FLAGS}"
export CXXFLAGS="${RPM_OPT_FLAGS}"

%{!?binutils_keep_build_dir:
rm -rf build-dir
}
# Remove gdb and sim since they have separate gdb package
rm -rf gdb sim

mkdir -p build-dir
cd build-dir

%{!?binutils_skip_configure:
%{?binutils_dump_configure:patch_configure.pl ..}   # Add debug prints into configure
../configure \
	--prefix=%{_prefix} --libdir=%{_libdir} \
	--infodir=%{_infodir} --mandir=%{_mandir} \
	--with-bugurl=http://bugs.tizen.org/ \
	--with-sysroot=/ \
	--disable-nls \
	--with-separate-debug-dir=%{_prefix}/lib/debug \
	--with-pic \
	--build=%{host_arch} --target=%{target_arch} \
	--host=%{host_arch} \
	%{?annobin_verification: --enable-annobin-verification=warn } \
	%{?annobin_verification_strict: --enable-annobin-verification=strict } \
%if 0%{?annobin_verification:1}%{?annobin_verification_strict:1} != 0
        --with-annobin-cxx11-abi-exceptions=libstdc++.a,libstdc++.so,libstdc++.so.6,libstdc++fs.a,compatibility.o,compatibility-c++0x.o,libc++98convenience.a,libc++11convenience.a,libc++17convenience.a,libc++20convenience.a \
%endif
%{?cross: \
	--enable-targets=%{target_arch} \
	--enable-64-bit-bfd \
} \
%{!?cross: \
	--enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
} \
	--enable-plugins \
	--enable-gold \
	--enable-shared \
	--enable-new-dtags \
	--enable-relro=no \
%ifarch %ix86
	--disable-separate-code
%endif

}

%{!?binutils_skip_make:
make %{?_smp_mflags}
%{?binutils_dump_configure:
 dump_configure.pl .. . \
		   --project binutils \
		   --project-version %{version} \
		   --out_db binutils-%{version}-%{release}-%_project-%_repository.db
 }
}

%{?binutils_exit_on_make_finish:
exit 1
}

%{?binutils_run_tests:
echo "Run testsuite"
# asan needs a whole shadow address space
ulimit -v unlimited || true
make -k check %{?_smp_mflags} || true
mkdir ../testresults
for tool in $(find -name '*.sum' -exec basename {} \; | sort -u | sed -e 's/.sum//'); do
../contrib/dg-extract-results.sh -t $tool $(find -name '*.sum') | tee -a ../testresults/test_summary.txt
done
}

%install
cd build-dir
make DESTDIR=$RPM_BUILD_ROOT install

# Copy instead of hardlinks
for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
do
  rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
%{!?cross:
  cp %{buildroot}%{_bindir}/$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
}
%{?cross:
  cp %{buildroot}%{_bindir}/%{target_arch}-$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
}
done

install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_prefix}/%{_lib}
install -m 644 ../include/libiberty.h %{buildroot}%{_prefix}/include

%{?binutils_run_tests:
  find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \;
  mkdir -p ../testresults && tar -xf testresults.tar -C ../testresults
  find ../testresults/ -type f -exec chmod 644 {} \;
}

# Remove unwanted files to shut up rpm
%{remove_docs}
rm -rf %{buildroot}%{_bindir}/gcore
rm -rf %{buildroot}%{_libdir}/lib{bfd,opcodes,inproctrace}.la
%{?cross:
rm -rf %{buildroot}%{_prefix}/%{target_arch}/lib/ldscripts
rm -rf %{buildroot}%{_prefix}/%{host_arch}
rm -rf %{buildroot}%{_includedir}
rm -rf %{buildroot}%{_prefix}/lib*
rm -rf %{buildroot}%{_datadir}
}

%{?binutils_dump_configure:
  install -D -m 0644 binutils-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
}

%files
%manifest binutils.manifest
%defattr(-,root,root)
%{_bindir}/*
%{_prefix}/%{target_arch}/bin/*
%{!?cross:
%exclude %{_bindir}/ld.gold
%exclude %{_prefix}/%{target_arch}/bin/ld.gold
%{_libdir}/*.so
%{_prefix}/%{host_arch}/lib/ldscripts

%files devel
%manifest binutils.manifest
%defattr(-,root,root)
%{_includedir}/*.h
%{_libdir}/*.a

%files gold
%manifest binutils.manifest
%defattr(-,root,root)
%{_bindir}/ld.gold
%{_prefix}/%{target_arch}/bin/ld.gold
}

%{?binutils_run_tests:
%files testresults
%defattr(-,root,root)
%doc testresults/test_summary.txt
%doc testresults/*
}

%{?binutils_dump_configure:
%files configure-dump
%manifest binutils.manifest
%{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
}

%changelog