Changes in tools/toolchain.sh [e6b4d2d:f3a7b0d] in mainline
- File:
-
- 1 edited
-
tools/toolchain.sh (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/toolchain.sh
re6b4d2d rf3a7b0d 31 31 BINUTILS_GDB_GIT="https://github.com/HelenOS/binutils-gdb.git" 32 32 33 BINUTILS_BRANCH="binutils-2_45-helenos" 34 BINUTILS_VERSION="2.45" 33 BINUTILS_BRANCH="binutils-2_31_1-helenos" 34 BINUTILS_VERSION="2.31.1" 35 36 GDB_BRANCH="gdb-8_2-helenos" 37 GDB_VERSION="8.2" 35 38 36 39 GCC_GIT="https://github.com/HelenOS/gcc.git" 37 GCC_BRANCH=" 15_2_0-helenos"38 GCC_VERSION=" 15.2"40 GCC_BRANCH="8_2_0-helenos" 41 GCC_VERSION="8.2.0" 39 42 40 43 BASEDIR="$PWD" 41 44 SRCDIR="$(readlink -f $(dirname "$0"))" 42 45 43 # If we install into a temporary directory and copy from there,44 # we don't have to trust the upstream makefiles respect the prefix for45 # all files, and we also have a ready-made package for distribution.46 INSTALL_DIR="${BASEDIR}/PKG"47 48 46 SYSTEM_INSTALL=false 49 50 BUILD_BINUTILS=true 51 BUILD_GCC=true 52 53 if [ -z "$JOBS" ] ; then 54 JOBS="`nproc`" 55 fi 47 REAL_INSTALL=true 48 USE_HELENOS_TARGET=true 56 49 57 50 check_error() { … … 68 61 echo 69 62 echo "Syntax:" 63 echo " $0 [--system-wide] [--no-install] [--non-helenos-target] <platform>" 70 64 echo " $0 [--system-wide] --test-version [<platform>]" 71 65 echo … … 82 76 echo " sparc64 SPARC V9" 83 77 echo " all build all targets" 78 echo " essential build only targets currently needed for HelenOS development" 84 79 echo " parallel same as 'all', but all in parallel" 85 80 echo " 2-way same as 'all', but 2-way parallel" … … 97 92 echo " variable is not set, then the default value of \$HOME/.local/share" 98 93 echo " is assumed." 94 echo 95 echo "If the --no-install option is used, the toolchain still uses the" 96 echo "target installation directory as determined above, but the files" 97 echo "are actually copied into the PKG/ subdirectory during the installation" 98 echo "without affecting the actual target file system. This might be useful" 99 echo "when preparing a system-wide installation, but avoiding running this" 100 echo "script under the super user." 99 101 echo 100 102 echo "The --non-helenos-target option will build non-HelenOS-specific" … … 137 139 for PLATFORM in $PLATFORMS ; do 138 140 set_target_from_platform "$PLATFORM" 139 PREFIX="${CROSS_PREFIX}/bin/${ TARGET}"141 PREFIX="${CROSS_PREFIX}/bin/${HELENOS_TARGET}" 140 142 141 143 echo "== $PLATFORM ==" 142 144 test_app_version "Binutils" "ld" "GNU ld (.*) \([.0-9]*\)" "$BINUTILS_VERSION" 143 145 test_app_version "GCC" "gcc" "gcc version \([.0-9]*\)" "$GCC_VERSION" 146 test_app_version "GDB" "gdb" "GNU gdb (.*)[[:space:]]\+\([.0-9]*\)" "$GDB_VERSION" 144 147 done 145 148 } … … 174 177 } 175 178 176 ring_bell() {177 printf '\a'178 sleep 0.1179 printf '\a'180 sleep 0.1181 printf '\a'182 sleep 0.1183 printf '\a'184 sleep 0.1185 printf '\a'186 }187 188 179 show_countdown() { 189 180 TM="$1" … … 250 241 251 242 check_dirs() { 252 cd "${BASEDIR}" 253 check_error $? "Unable to change directory to ${BASEDIR}." 243 OUTSIDE="$1" 244 BASE="$2" 245 ORIGINAL="$PWD" 246 247 cd "${BASE}" 248 check_error $? "Unable to change directory to ${BASE}." 254 249 ABS_BASE="$PWD" 255 256 if $SYSTEM_INSTALL && [ ! -d "${CROSS_PREFIX}" ]; then 257 ring_bell 258 ( set -x ; sudo -k mkdir -p "${CROSS_PREFIX}" ) 259 else 260 ( set -x ; mkdir -p "${CROSS_PREFIX}" ) 261 fi 262 263 cd "${CROSS_PREFIX}" 264 check_error $? "Unable to change directory to ${CROSS_PREFIX}." 250 cd "${ORIGINAL}" 251 check_error $? "Unable to change directory to ${ORIGINAL}." 252 253 mkdir -p "${OUTSIDE}" 254 cd "${OUTSIDE}" 255 check_error $? "Unable to change directory to ${OUTSIDE}." 265 256 266 257 while [ "${#PWD}" -gt "${#ABS_BASE}" ]; do … … 275 266 fi 276 267 277 cd "${BASEDIR}" 268 cd "${ORIGINAL}" 269 check_error $? "Unable to change directory to ${ORIGINAL}." 278 270 } 279 271 … … 288 280 change_title "Downloading sources" 289 281 echo ">>> Downloading sources" 290 291 if $BUILD_BINUTILS ; then 292 git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION" 293 # If the directory already existed, pull upstream changes. 294 git -C "binutils-$BINUTILS_VERSION" pull 295 fi 296 297 if $BUILD_GCC ; then 298 git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION" 299 git -C "gcc-$GCC_VERSION" pull 300 301 change_title "Downloading GCC prerequisites" 302 echo ">>> Downloading GCC prerequisites" 303 cd "gcc-${GCC_VERSION}" 304 ./contrib/download_prerequisites 305 cd .. 306 fi 307 308 # This sets the CROSS_PREFIX variable 309 set_cross_prefix 310 311 DESTDIR_SPEC="DESTDIR=${INSTALL_DIR}" 312 313 check_dirs 282 git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION" 283 git clone --depth 1 -b "$GDB_BRANCH" "$BINUTILS_GDB_GIT" "gdb-$GDB_VERSION" 284 git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION" 285 286 # If the directory already existed, pull upstream changes. 287 git -C "binutils-$BINUTILS_VERSION" pull 288 git -C "gdb-$GDB_VERSION" pull 289 git -C "gcc-$GCC_VERSION" pull 290 291 change_title "Downloading GCC prerequisites" 292 echo ">>> Downloading GCC prerequisites" 293 cd "gcc-${GCC_VERSION}" 294 ./contrib/download_prerequisites 295 cd .. 314 296 } 315 297 … … 339 321 esac 340 322 341 TARGET="${GNU_ARCH}-helenos" 342 } 343 344 build_binutils() { 345 # This sets the TARGET variable 346 set_target_from_platform "$1" 323 HELENOS_TARGET="${GNU_ARCH}-helenos" 324 325 case "$1" in 326 "arm32") 327 LINUX_TARGET="${GNU_ARCH}-linux-gnueabi" 328 ;; 329 *) 330 LINUX_TARGET="${GNU_ARCH}-linux-gnu" 331 ;; 332 esac 333 } 334 335 build_target() { 336 PLATFORM="$1" 337 338 # This sets the *_TARGET variables 339 set_target_from_platform "$PLATFORM" 340 if $USE_HELENOS_TARGET ; then 341 TARGET="$HELENOS_TARGET" 342 else 343 TARGET="$LINUX_TARGET" 344 fi 347 345 348 346 WORKDIR="${BASEDIR}/${TARGET}" 347 INSTALL_DIR="${BASEDIR}/PKG" 349 348 BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}" 349 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" 350 GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}" 351 352 # This sets the CROSS_PREFIX variable 353 set_cross_prefix 354 355 if [ -z "$JOBS" ] ; then 356 JOBS="`nproc`" 357 fi 358 359 PREFIX="${CROSS_PREFIX}" 350 360 351 361 echo ">>> Removing previous content" 352 362 cleanup_dir "${WORKDIR}" 353 363 mkdir -p "${WORKDIR}" 354 355 echo ">>> Processing binutils (${TARGET})" 364 check_dirs "${PREFIX}" "${WORKDIR}" 365 366 if $USE_HELENOS_TARGET ; then 367 change_title "Creating build sysroot" 368 echo ">>> Creating build sysroot" 369 mkdir -p "${WORKDIR}/sysroot/include" 370 mkdir "${WORKDIR}/sysroot/lib" 371 ARCH="$PLATFORM" 372 if [ "$ARCH" = "mips32eb" ]; then 373 ARCH=mips32 374 fi 375 376 cp -r -L -t "${WORKDIR}/sysroot/include" \ 377 ${SRCDIR}/../abi/include/* \ 378 ${SRCDIR}/../uspace/lib/c/arch/${ARCH}/include/* \ 379 ${SRCDIR}/../uspace/lib/c/include/* 380 check_error $? "Failed to create build sysroot." 381 fi 382 383 384 echo ">>> Processing binutils (${PLATFORM})" 356 385 mkdir -p "${BINUTILSDIR}" 357 386 cd "${BINUTILSDIR}" 358 387 check_error $? "Change directory failed." 359 388 360 change_title "binutils: configure (${ TARGET})"389 change_title "binutils: configure (${PLATFORM})" 361 390 CFLAGS="-Wno-error -fcommon" "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \ 362 391 "--target=${TARGET}" \ 363 "--prefix=${ CROSS_PREFIX}" \392 "--prefix=${PREFIX}" \ 364 393 "--program-prefix=${TARGET}-" \ 365 394 --disable-nls \ 366 395 --disable-werror \ 367 -- disable-gold \396 --enable-gold \ 368 397 --enable-deterministic-archives \ 369 398 --disable-gdb \ … … 371 400 check_error $? "Error configuring binutils." 372 401 373 change_title "binutils: make (${ TARGET})"402 change_title "binutils: make (${PLATFORM})" 374 403 make all -j$JOBS 375 404 check_error $? "Error compiling binutils." 376 405 377 change_title "binutils: install (${ TARGET})"378 make install $DESTDIR_SPEC406 change_title "binutils: install (${PLATFORM})" 407 make install "DESTDIR=${INSTALL_DIR}" 379 408 check_error $? "Error installing binutils." 380 } 381 382 build_gcc() { 383 # This sets the TARGET variable 384 set_target_from_platform "$1" 385 386 WORKDIR="${BASEDIR}/${TARGET}" 387 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" 388 389 echo ">>> Removing previous content" 390 cleanup_dir "${WORKDIR}" 391 mkdir -p "${WORKDIR}" 392 393 echo ">>> Processing GCC (${TARGET})" 409 410 411 echo ">>> Processing GCC (${PLATFORM})" 394 412 mkdir -p "${GCCDIR}" 395 413 cd "${GCCDIR}" 396 414 check_error $? "Change directory failed." 397 415 398 BUILDPATH="${CROSS_PREFIX}/bin:${PATH}" 399 400 change_title "GCC: configure (${TARGET})" 401 PATH="${BUILDPATH}" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \ 416 if $USE_HELENOS_TARGET ; then 417 SYSROOT=--with-sysroot --with-build-sysroot="${WORKDIR}/sysroot" 418 else 419 SYSROOT=--without-headers 420 fi 421 422 change_title "GCC: configure (${PLATFORM})" 423 PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \ 402 424 "--target=${TARGET}" \ 403 "--prefix=${ CROSS_PREFIX}" \425 "--prefix=${PREFIX}" \ 404 426 "--program-prefix=${TARGET}-" \ 405 427 --with-gnu-as \ … … 408 430 --enable-languages=c,c++,go \ 409 431 --enable-lto \ 410 --enable-obsolete \411 432 --disable-shared \ 412 433 --disable-werror \ 413 --without-headers # TODO: Replace with proper sysroot so we can build more libs434 $SYSROOT 414 435 check_error $? "Error configuring GCC." 415 436 416 change_title "GCC: make (${ TARGET})"417 PATH="${ BUILDPATH}" make all-gcc -j$JOBS437 change_title "GCC: make (${PLATFORM})" 438 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS 418 439 check_error $? "Error compiling GCC." 419 440 420 change_title "GCC: install (${TARGET})" 421 PATH="${BUILDPATH}" make install-gcc $DESTDIR_SPEC 441 if $USE_HELENOS_TARGET ; then 442 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libgcc -j$JOBS 443 check_error $? "Error compiling libgcc." 444 # TODO: libatomic and libstdc++ need some extra care 445 # PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS 446 # check_error $? "Error compiling libatomic." 447 # PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS 448 # check_error $? "Error compiling libstdc++." 449 fi 450 451 change_title "GCC: install (${PLATFORM})" 452 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}" 453 if $USE_HELENOS_TARGET ; then 454 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libgcc "DESTDIR=${INSTALL_DIR}" 455 # PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libatomic "DESTDIR=${INSTALL_DIR}" 456 # PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libstdc++-v3 "DESTDIR=${INSTALL_DIR}" 457 fi 422 458 check_error $? "Error installing GCC." 423 } 424 425 build_libgcc() { 426 # This sets the TARGET variable 427 set_target_from_platform "$1" 428 429 WORKDIR="${BASEDIR}/${TARGET}" 430 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" 431 432 # No removing previous content here, we need the previous GCC build 433 434 cd "${GCCDIR}" 459 460 461 echo ">>> Processing GDB (${PLATFORM})" 462 mkdir -p "${GDBDIR}" 463 cd "${GDBDIR}" 435 464 check_error $? "Change directory failed." 436 465 437 BUILDPATH="${CROSS_PREFIX}/bin:${PATH}" 438 439 change_title "libgcc: make (${TARGET})" 440 441 PATH="${BUILDPATH}" make all-target-libgcc -j$JOBS 442 check_error $? "Error compiling libgcc." 443 # TODO: libatomic and libstdc++ need some extra care 444 # PATH="${BUILDPATH}" make all-target-libatomic -j$JOBS 445 # check_error $? "Error compiling libatomic." 446 # PATH="${BUILDPATH}" make all-target-libstdc++-v3 -j$JOBS 447 # check_error $? "Error compiling libstdc++." 448 449 change_title "libgcc: install (${TARGET})" 450 451 PATH="${BUILDPATH}" make install-target-libgcc $DESTDIR_SPEC 452 # PATH="${BUILDPATH}" make install-target-libatomic $DESTDIR_SPEC 453 # PATH="${BUILDPATH}" make install-target-libstdc++-v3 $DESTDIR_SPEC 454 check_error $? "Error installing libgcc." 455 } 456 457 install_pkg() { 458 echo ">>> Moving to the destination directory." 459 if $SYSTEM_INSTALL ; then 460 ring_bell 461 ( set -x ; tar -C "${INSTALL_DIR}${CROSS_PREFIX}" -cpf - . | sudo -k tar -C "${CROSS_PREFIX}" -xpf - ) 462 else 463 ( set -x ; tar -C "${INSTALL_DIR}${CROSS_PREFIX}" -cpf - . | tar -C "${CROSS_PREFIX}" -xpf - ) 464 fi 465 } 466 467 link_clang() { 466 change_title "GDB: configure (${PLATFORM})" 467 CFLAGS="-fcommon" PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \ 468 "--target=${TARGET}" \ 469 "--prefix=${PREFIX}" \ 470 "--program-prefix=${TARGET}-" \ 471 --enable-werror=no 472 check_error $? "Error configuring GDB." 473 474 change_title "GDB: make (${PLATFORM})" 475 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gdb -j$JOBS 476 check_error $? "Error compiling GDB." 477 478 change_title "GDB: make (${PLATFORM})" 479 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gdb "DESTDIR=${INSTALL_DIR}" 480 check_error $? "Error installing GDB." 481 468 482 # Symlink clang and lld to the install path. 469 483 CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`" 470 CLANGPP="`which clang++ 2> /dev/null || echo "/usr/bin/clang++"`"471 484 LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`" 472 485 473 ln -s $CLANG "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-clang" 474 ln -s $CLANGPP "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-clang++" 475 ln -s $LLD "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-ld.lld" 486 ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang" 487 ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld" 488 489 if $REAL_INSTALL ; then 490 echo ">>> Moving to the destination directory." 491 cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"* 492 fi 493 494 cd "${BASEDIR}" 495 check_error $? "Change directory failed." 496 497 echo ">>> Cleaning up" 498 cleanup_dir "${WORKDIR}" 499 500 echo 501 echo ">>> Cross-compiler for ${TARGET} installed." 476 502 } 477 503 … … 486 512 exit 487 513 ;; 514 --no-install) 515 REAL_INSTALL=false 516 shift 517 ;; 518 --non-helenos-target) 519 USE_HELENOS_TARGET=false 520 shift 521 ;; 488 522 *) 489 523 show_usage … … 495 529 show_usage 496 530 fi 497 498 PLATFORMS="amd64 arm32 arm64 ia32 ia64 mips32 mips32eb ppc32 riscv64 sparc64"499 500 run_one() {501 $1 $PLATFORM502 }503 504 run_all() {505 for x in $PLATFORMS ; do506 $1 $x507 done508 }509 510 run_parallel() {511 for x in $PLATFORMS ; do512 $1 $x &513 done514 wait515 }516 517 run_2way() {518 $1 amd64 &519 $1 arm32 &520 wait521 522 $1 arm64 &523 $1 ia32 &524 wait525 526 $1 ia64 &527 $1 mips32 &528 wait529 530 $1 mips32eb &531 $1 ppc32 &532 wait533 534 $1 riscv64 &535 $1 sparc64 &536 wait537 }538 539 everything() {540 RUNNER="$1"541 542 prepare543 544 if $BUILD_BINUTILS ; then545 $RUNNER build_binutils546 547 if $BUILD_GCC ; then548 # gcc/libgcc may fail to build correctly if binutils is not installed first549 echo ">>> Installing binutils"550 install_pkg551 fi552 fi553 554 if $BUILD_GCC ; then555 $RUNNER build_gcc556 557 # libgcc may fail to build correctly if gcc is not installed first558 echo ">>> Installing GCC"559 install_pkg560 561 $RUNNER build_libgcc562 fi563 564 echo ">>> Installing all files"565 install_pkg566 567 link_clang568 }569 531 570 532 case "$1" in … … 574 536 ;; 575 537 amd64|arm32|arm64|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64) 576 PLATFORM="$1"577 everything run_one538 prepare 539 build_target "$1" 578 540 ;; 579 541 "all") 580 everything run_all 542 prepare 543 build_target "amd64" 544 build_target "arm32" 545 build_target "arm64" 546 build_target "ia32" 547 build_target "ia64" 548 build_target "mips32" 549 build_target "mips32eb" 550 build_target "ppc32" 551 build_target "riscv64" 552 build_target "sparc64" 553 ;; 554 "essential") 555 prepare 556 build_target "amd64" 557 build_target "arm32" 558 build_target "arm64" 559 build_target "ia32" 560 build_target "ia64" 561 build_target "mips32" 562 build_target "mips32eb" 563 build_target "ppc32" 564 build_target "sparc64" 581 565 ;; 582 566 "parallel") 583 everything run_parallel 567 prepare 568 build_target "amd64" & 569 build_target "arm32" & 570 build_target "arm64" & 571 build_target "ia32" & 572 build_target "ia64" & 573 build_target "mips32" & 574 build_target "mips32eb" & 575 build_target "ppc32" & 576 build_target "riscv64" & 577 build_target "sparc64" & 578 wait 584 579 ;; 585 580 "2-way") 586 everything run_2way 581 prepare 582 build_target "amd64" & 583 build_target "arm32" & 584 wait 585 586 build_target "arm64" & 587 build_target "ia32" & 588 wait 589 590 build_target "ia64" & 591 build_target "mips32" & 592 wait 593 594 build_target "mips32eb" & 595 build_target "ppc32" & 596 wait 597 598 build_target "riscv64" & 599 build_target "sparc64" & 600 wait 587 601 ;; 588 602 *)
Note:
See TracChangeset
for help on using the changeset viewer.
