Check-in [78c40ae32f]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tool versioning improvements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 78c40ae32fe9e563e49a650ecebb44cb3dc66ea0
User & Date: rkeene 2019-05-08 21:56:26
Context
2019-05-08
21:57
NetBSD 8 requires some ctype work check-in: 22acd7c457 user: rkeene tags: trunk
21:56
Tool versioning improvements check-in: 78c40ae32f user: rkeene tags: trunk
2018-02-19
16:02
Make "setup-cc" more selective about what it considers available toolchains check-in: a97508d2ea user: rkeene tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to build-cc.

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
## Load configuration file
if [ -f "build-cc.conf" ]; then
	. "build-cc.conf"
fi

# Tool versions
## SHA1 may be left blank to disable hashing





















if [ -z "${BINUTILS_VERS}" ]; then
	BINUTILS_VERS='2.29.1'
	BINUTILS_SHA1='5156099a6c50bd330c3d4c8fc56a9bf725ccaf08'
fi
if [ -z "${GCC_VERS}" ]; then
	GCC_VERS='7.3.0'
	GCC_SHA1='9689b9cae7b2886fdaa08449a26701f095c04e48'
fi
if [ -z "${GMP_VERS}" ]; then
	GMP_VERS='6.1.2'
	GMP_SHA1='366ded6a44cd108ba6b3f5b9a252eab3f3a95cdf'
fi
if [ -z "${MPFR_VERS}" ]; then
	MPFR_VERS='4.0.0'
	MPFR_SHA1='799245347044c8f0da9e513f86bb5e4c07974931'
fi
if [ -z "${MPC_VERS}" ]; then
	MPC_VERS='1.1.0'
	MPC_SHA1='b019d9e1d27ec5fb99497159d43a3164995de2d0'
fi

# Start of script
## Initialize default values
use_multilib="${BUILD_CC_MULTILIB_DEFAULT:-1}"
use_gnu_ld='1'
use_gnu_as='1'







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
<


|
<



<


|
<



<







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
## Load configuration file
if [ -f "build-cc.conf" ]; then
	. "build-cc.conf"
fi

# Tool versions
## SHA1 may be left blank to disable hashing
declare -A tool_hash
tool_hash["binutils-2.25.1.tar.bz2"]='b5b14added7d78a8d1ca70b5cb75fef57ce2197264f4f5835326b0df22ac9f22'
tool_hash["binutils-2.25.tar.bz2"]='22defc65cfa3ef2a3395faaea75d6331c6e62ea5dfacfed3e2ec17b08c882923'
tool_hash["binutils-2.29.1.tar.bz2"]='1509dff41369fb70aed23682351b663b56db894034773e6dbf7d5d6071fc55cc'
tool_hash["binutils-2.32.tar.bz2"]='de38b15c902eb2725eac6af21183a5f34ea4634cb0bcef19612b50e5ed31072d'
tool_hash["gcc-4.9.2.tar.bz2"]='2020c98295856aa13fda0f2f3a4794490757fc24bcca918d52cc8b4917b972dd'
tool_hash["gcc-6.2.0.tar.bz2"]='9944589fc722d3e66308c0ce5257788ebd7872982a718aa2516123940671b7c5'
tool_hash["gcc-7.3.0.tar.xz"]='832ca6ae04636adbb430e865a1451adf6979ab44ca1c8374f61fba65645ce15c'
tool_hash["gcc-9.1.0.tar.xz"]='79a66834e96a6050d8fe78db2c3b32fb285b230b855d0a66288235bc04b327a0'
tool_hash["glibc-2.22.tar.gz"]='a62610c4084a0fd8cec58eee12ef9e61fdf809c31e7cecbbc28feb8719f08be5'
tool_hash["glibc-2.26.tar.gz"]='dcc2482b00fdb1c316f385f8180e182bbd37c065dc7d8281a4339d2834ef1be7'
tool_hash["glibc-2.27.tar.gz"]='881ca905e6b5eec724de7948f14d66a07d97bdee8013e1b2a7d021ff5d540522'
tool_hash["glibc-ports-2.16.0.tar.gz"]='1092e81d0c9c1bc29343004c1d01fb0d89eb49dd0fd5339b2f2e64a44b582d10'
tool_hash["gmp-6.0.0a.tar.bz2"]='7f8e9a804b9c6d07164cf754207be838ece1219425d64e28cfa3e70d5c759aaf'
tool_hash["gmp-6.1.2.tar.bz2"]='5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2'
tool_hash["mpc-1.0.2.tar.gz"]='b561f54d8a479cee3bc891ee52735f18ff86712ba30f036f8b8537bae380c488'
tool_hash["mpc-1.1.0.tar.gz"]='6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e'
tool_hash["mpfr-3.1.2.tar.bz2"]='79c73f60af010a30a5c27a955a1d2d01ba095b72537dab0ecaad57f5a7bb1b6b'
tool_hash["mpfr-4.0.0.tar.bz2"]='6aa31fbf3bd1f9f95bcfa241590a9d11cb0f874e2bb93b99c9e2de8eaea6d5fd'
tool_hash["mpfr-4.0.0.tar.xz"]='fbe2cd1418b321f5c899ce4f0f0f4e73f5ecc7d02145b0e1fd096f5c3afb8a1d'
tool_hash["mpfr-4.0.2.tar.xz"]='1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a'
if [ -z "${BINUTILS_VERS}" ]; then
	BINUTILS_VERS='2.32'

fi
if [ -z "${GCC_VERS}" ]; then
	GCC_VERS='9.1.0'

fi
if [ -z "${GMP_VERS}" ]; then
	GMP_VERS='6.1.2'

fi
if [ -z "${MPFR_VERS}" ]; then
	MPFR_VERS='4.0.2'

fi
if [ -z "${MPC_VERS}" ]; then
	MPC_VERS='1.1.0'

fi

# Start of script
## Initialize default values
use_multilib="${BUILD_CC_MULTILIB_DEFAULT:-1}"
use_gnu_ld='1'
use_gnu_as='1'
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
		else
			echo "Proceeding anyway due to BUILD_CC_FORCE_PLATFORM" >&2
		fi
	fi
fi

## Load user-supplied profiles
. "${TOPDIR}/platform/${platform}.sh"




## URLs
### Binutils
if [ -z "${BINUTILS_URL}" ]; then
	BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERS}.tar.bz2"
fi
BINUTILS_TARBALL="src/binutils-${BINUTILS_VERS}.tar.bz2"
BINUTILS_DIR="binutils-${BINUTILS_VERS}"


### GCC
if [ -z "${GCC_URL}" ]; then
	GCC_URL="http://mirrors.kernel.org/gnu/gcc/gcc-${GCC_VERS}/gcc-${GCC_VERS}.tar.xz"
fi
GCC_TARBALL="src/gcc-${GCC_VERS}.tar.xz"
GCC_DIR="gcc-${GCC_VERS}"


### GMP
if [ -z "${GMP_URL}" ]; then
	GMP_URL="http://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERS}.tar.bz2"
fi
GMP_TARBALL="src/gmp-${GMP_VERS}.tar.bz2"
GMP_DIR="gmp-$(echo "${GMP_VERS}" | sed 's@[a-zA-Z]*$@@')"


### MPFR
if [ -z "${MPFR_URL}" ]; then
	MPFR_URL="http://www.mpfr.org/mpfr-${MPFR_VERS}/mpfr-${MPFR_VERS}.tar.bz2"
fi
MPFR_TARBALL="src/mpfr-${MPFR_VERS}.tar.bz2"
MPFR_DIR="mpfr-${MPFR_VERS}"


### MPC
if [ -z "${MPC_URL}" ]; then
	MPC_URL="https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERS}.tar.gz"
fi
MPC_TARBALL="src/mpc-${MPC_VERS}.tar.gz"
MPC_DIR="mpc-${MPC_VERS}"


## Clean-up
if [ "$1" = "clean" -o "$1" = "distclean" ]; then
	rm -rf "${BINUTILS_DIR}" "${GCC_DIR}" "${GMP_DIR}" "${MPFR_DIR}" "${MPC_DIR}"

	for platform in "${platforms[@]}"; do
		rm -rf "gcc-${platform}"







|
>
>
>








>







>







>



|

|

>







>







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
		else
			echo "Proceeding anyway due to BUILD_CC_FORCE_PLATFORM" >&2
		fi
	fi
fi

## Load user-supplied profiles
platformProfileScript="${TOPDIR}/platform/${platform}.sh"
if [ -f "${platformProfileScript}" ]; then
	. "${platformProfileScript}"
fi

## URLs
### Binutils
if [ -z "${BINUTILS_URL}" ]; then
	BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERS}.tar.bz2"
fi
BINUTILS_TARBALL="src/binutils-${BINUTILS_VERS}.tar.bz2"
BINUTILS_DIR="binutils-${BINUTILS_VERS}"
BINUTILS_HASH="${tool_hash[$(basename "${BINUTILS_TARBALL}")]}"

### GCC
if [ -z "${GCC_URL}" ]; then
	GCC_URL="http://mirrors.kernel.org/gnu/gcc/gcc-${GCC_VERS}/gcc-${GCC_VERS}.tar.xz"
fi
GCC_TARBALL="src/gcc-${GCC_VERS}.tar.xz"
GCC_DIR="gcc-${GCC_VERS}"
GCC_HASH="${tool_hash[$(basename "${GCC_TARBALL}")]}"

### GMP
if [ -z "${GMP_URL}" ]; then
	GMP_URL="http://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERS}.tar.bz2"
fi
GMP_TARBALL="src/gmp-${GMP_VERS}.tar.bz2"
GMP_DIR="gmp-$(echo "${GMP_VERS}" | sed 's@[a-zA-Z]*$@@')"
GMP_HASH="${tool_hash[$(basename "${GMP_TARBALL}")]}"

### MPFR
if [ -z "${MPFR_URL}" ]; then
	MPFR_URL="http://www.mpfr.org/mpfr-${MPFR_VERS}/mpfr-${MPFR_VERS}.tar.xz"
fi
MPFR_TARBALL="src/mpfr-${MPFR_VERS}.tar.xz"
MPFR_DIR="mpfr-${MPFR_VERS}"
MPFR_HASH="${tool_hash[$(basename "${MPFR_TARBALL}")]}"

### MPC
if [ -z "${MPC_URL}" ]; then
	MPC_URL="https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERS}.tar.gz"
fi
MPC_TARBALL="src/mpc-${MPC_VERS}.tar.gz"
MPC_DIR="mpc-${MPC_VERS}"
MPC_HASH="${tool_hash[$(basename "${MPC_TARBALL}")]}"

## Clean-up
if [ "$1" = "clean" -o "$1" = "distclean" ]; then
	rm -rf "${BINUTILS_DIR}" "${GCC_DIR}" "${GMP_DIR}" "${MPFR_DIR}" "${MPC_DIR}"

	for platform in "${platforms[@]}"; do
		rm -rf "gcc-${platform}"
279
280
281
282
283
284
285

286
287

288
289
290
291






292
293
294
295
296
297
298
	cd "${CCDIR}/${CCNAME}" || exit 1

	if [ ! -e 'usr' ]; then
		#### Create symlink so things like "./usr/include" work.
		ln -s . usr
	fi


	if [ -f "${PLATFORM_TARBALL}" ]; then
		bzip2 -dc "${PLATFORM_TARBALL}" | "${TAR:-tar}" --keep-old-files -xf - >/dev/null 2>/dev/null

	fi

	if [ -f "${ADDONS_TARBALL}" ]; then
		bzip2 -dc "${ADDONS_TARBALL}" | "${TAR:-tar}" --keep-old-files -xf - >/dev/null 2>/dev/null






	fi
)

### Set use_multilib authoritatively if possible
if [ -f "${CCDIR}/${CCNAME}/multilib" ]; then
	use_multilib="$(cat "${CCDIR}/${CCNAME}/multilib")"
	rm -f "${CCDIR}/${CCNAME}/multilib"







>


>




>
>
>
>
>
>







303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
	cd "${CCDIR}/${CCNAME}" || exit 1

	if [ ! -e 'usr' ]; then
		#### Create symlink so things like "./usr/include" work.
		ln -s . usr
	fi

	fixPerms='false'
	if [ -f "${PLATFORM_TARBALL}" ]; then
		bzip2 -dc "${PLATFORM_TARBALL}" | "${TAR:-tar}" --keep-old-files -xf - >/dev/null 2>/dev/null
		fixPerms='true'
	fi

	if [ -f "${ADDONS_TARBALL}" ]; then
		bzip2 -dc "${ADDONS_TARBALL}" | "${TAR:-tar}" --keep-old-files -xf - >/dev/null 2>/dev/null
		fixPerms='true'
	fi

	if [ "${fixPerms}" = 'true' ]; then
		find . -type d -exec chmod u+rx '{}' ';'
		find . -type f -exec chmod u+r '{}' ';'
	fi
)

### Set use_multilib authoritatively if possible
if [ -f "${CCDIR}/${CCNAME}/multilib" ]; then
	use_multilib="$(cat "${CCDIR}/${CCNAME}/multilib")"
	rm -f "${CCDIR}/${CCNAME}/multilib"
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
			exit 0
		fi
	fi

	echo " * Building GNU Binutils version ${BINUTILS_VERS} for ${CCNAME}"

	if [ ! -d "${BINUTILS_DIR}" ]; then
		download "${BINUTILS_URL}" "${BINUTILS_TARBALL}" "${BINUTILS_SHA1}" || exit 1

		bzip2 -dc "${BINUTILS_TARBALL}" | tar -xf -

		# Apply patches
		## Apply patch files
		for patchfile in "$(pwd)/patches/binutils"/*.diff; do
			(







|







418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
			exit 0
		fi
	fi

	echo " * Building GNU Binutils version ${BINUTILS_VERS} for ${CCNAME}"

	if [ ! -d "${BINUTILS_DIR}" ]; then
		download "${BINUTILS_URL}" "${BINUTILS_TARBALL}" "${BINUTILS_HASH}" || exit 1

		bzip2 -dc "${BINUTILS_TARBALL}" | tar -xf -

		# Apply patches
		## Apply patch files
		for patchfile in "$(pwd)/patches/binutils"/*.diff; do
			(
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
	echo " * Building GNU C Compiler version ${GCC_VERS} for ${CCNAME}, ${STAGE}"

	if [ ! -d "${GCC_DIR}" ]; then
		# Sanity
		rm -rf "gcc-${GCC_VERS}"

		# Download sources required
		download "${GCC_URL}" "${GCC_TARBALL}" "${GCC_SHA1}" || exit 1
		download "${GMP_URL}" "${GMP_TARBALL}" "${GMP_SHA1}" || exit 1
		download "${MPFR_URL}" "${MPFR_TARBALL}" "${MPFR_SHA1}" || exit 1
		download "${MPC_URL}" "${MPC_TARBALL}" "${MPC_SHA1}" || exit 1

		# Extract sources

		xz -dc "${GCC_TARBALL}" | "${TAR:-tar}" -xf -
		bzip2 -dc "${GMP_TARBALL}" | "${TAR:-tar}" -xf -
		bzip2 -dc "${MPFR_TARBALL}" | "${TAR:-tar}" -xf -
		gzip -dc "${MPC_TARBALL}" | "${TAR:-tar}" -xf -

		# Rename GCC dir to the name we need
		rm -rf "${GCC_DIR}"
		mv "gcc-${GCC_VERS}" "${GCC_DIR}"

		# Arrange sources as needed







|
|
|
|





|







492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
	echo " * Building GNU C Compiler version ${GCC_VERS} for ${CCNAME}, ${STAGE}"

	if [ ! -d "${GCC_DIR}" ]; then
		# Sanity
		rm -rf "gcc-${GCC_VERS}"

		# Download sources required
		download "${GCC_URL}" "${GCC_TARBALL}" "${GCC_HASH}" || exit 1
		download "${GMP_URL}" "${GMP_TARBALL}" "${GMP_HASH}" || exit 1
		download "${MPFR_URL}" "${MPFR_TARBALL}" "${MPFR_HASH}" || exit 1
		download "${MPC_URL}" "${MPC_TARBALL}" "${MPC_HASH}" || exit 1

		# Extract sources

		xz -dc "${GCC_TARBALL}" | "${TAR:-tar}" -xf -
		bzip2 -dc "${GMP_TARBALL}" | "${TAR:-tar}" -xf -
		xz -dc "${MPFR_TARBALL}" | "${TAR:-tar}" -xf -
		gzip -dc "${MPC_TARBALL}" | "${TAR:-tar}" -xf -

		# Rename GCC dir to the name we need
		rm -rf "${GCC_DIR}"
		mv "gcc-${GCC_VERS}" "${GCC_DIR}"

		# Arrange sources as needed

Changes to scripts/common.

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
#! /bin/bash

# Functions













































function download () {
	local url
	local file
	local checksum dl_checksum
	local tmpfile

	url="$1"
	file="$2"
	checksum="$3"

	if [ -n "${BUILD_CC_DOWNLOAD_HELPER}" ]; then
		"${BUILD_CC_DOWNLOAD_HELPER}" "${url}" "${file}" "${checksum}"

		return "$?"
	fi















	tmpfile="${file}.tmp"

	if [ -s "${file}" ]; then
		return 0
	fi

	mkdir -p "$(dirname "${tmpfile}")" 2>/dev/null >/dev/null

	rm -f "${tmpfile}"




	wget -O "${tmpfile}" "${url}" || return 1


	if [ -n "${checksum}" ]; then
		case "${checksum}" in
			????????????????????????????????????????)

				dl_checksum="$(openssl dgst -sha1 "${tmpfile}" 2>/dev/null | sed 's@.*= *@@')"
				;;
			????????????????????????????????????????????????????????????????)

				dl_checksum="$(openssl dgst -sha256 "${tmpfile}" 2>/dev/null | sed 's@.*= *@@')"
				;;
			*)
				echo "Invalid checksum value: ${checksum}" >&2

				exit 1
				;;
		esac


		if [ "${checksum}" != "${dl_checksum}" ]; then
			echo "Checksum mismatch.  Got checksum: ${dl_checksum}; Expected checksum: ${checksum}" >&2

			return 1
		fi
	fi




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|











>
>
>
>
>
>
>
>
>
>
>
>
>
>










>
>
>
>
|
>

<
|
<
>
|
|
<
>
|
|
<
<
<
<
<
|

>







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
#! /bin/bash

# Functions
function _download_file() {
	local file url headers
	local header
	local try_download_command
	local args

	file="$1"
	url="$2"
	shift 2
	headers=("$@")

	if [ -z "${_download_command}" ]; then
		for try_download_command in curl wget; do
			if command -v "${try_download_command}" 2>/dev/null >/dev/null; then
				_download_command="${try_download_command}"

				break
			fi
		done
	fi

	args=()
	for header in "${headers[@]}"; do
		case "${_download_command}" in
			curl)
				args+=(--header "${header}")
				;;
			wget)
				args+=(--header="${header}")
				;;
		esac
	done

	case "${_download_command}" in
		curl)
			curl "${args[@]}" --silent --show-error --location --output "${file}" "${url}" || return 1
			;;
		wget)
			wget "${args[@]}" --output-document="${file}" "${url}" || return 1
			;;
	esac

	return 0
}

function download () {
	local url
	local file
	local checksum dl_checksum checksum_type
	local tmpfile

	url="$1"
	file="$2"
	checksum="$3"

	if [ -n "${BUILD_CC_DOWNLOAD_HELPER}" ]; then
		"${BUILD_CC_DOWNLOAD_HELPER}" "${url}" "${file}" "${checksum}"

		return "$?"
	fi

	checksum_type='unknown'
	if [ -n "${checksum}" ]; then
		case "${checksum}" in
			????????????????????????????????????????)
				checksum_type='sha1'
				;;
			????????????????????????????????????????????????????????????????)
				checksum_type='sha256'
				;;
			*)
				;;
		esac
	fi

	tmpfile="${file}.tmp"

	if [ -s "${file}" ]; then
		return 0
	fi

	mkdir -p "$(dirname "${tmpfile}")" 2>/dev/null >/dev/null

	rm -f "${tmpfile}"
	if [ "${checksum_type}" != 'unknown' ]; then
		_download_file "${tmpfile}" "http://hashcache.rkeene.org/${checksum_type}/${checksum}" "X-Cache-URL: ${url}" || rm -f "${tmpfile}"
	fi
	if [ ! -s "${tmpfile}" ]; then
		_download_file "${tmpfile}" "${url}"
	fi


	case "${checksum_type}" in

		sha1)
			dl_checksum="$(openssl dgst -sha1 "${tmpfile}" 2>/dev/null | sed 's@.*= *@@')"
			;;

		sha256)
			dl_checksum="$(openssl dgst -sha256 "${tmpfile}" 2>/dev/null | sed 's@.*= *@@')"
			;;





	esac

	if [ "${checksum_type}" != 'unknown' ]; then
		if [ "${checksum}" != "${dl_checksum}" ]; then
			echo "Checksum mismatch.  Got checksum: ${dl_checksum}; Expected checksum: ${checksum}" >&2

			return 1
		fi
	fi