Changes in tools/toolchain.sh [f3a7b0d:e6b4d2d] in mainline
- File:
-
- 1 edited
-
tools/toolchain.sh (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/toolchain.sh
rf3a7b0d re6b4d2d 31 31 BINUTILS_GDB_GIT="https://github.com/HelenOS/binutils-gdb.git" 32 32 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" 33 BINUTILS_BRANCH="binutils-2_45-helenos" 34 BINUTILS_VERSION="2.45" 38 35 39 36 GCC_GIT="https://github.com/HelenOS/gcc.git" 40 GCC_BRANCH=" 8_2_0-helenos"41 GCC_VERSION=" 8.2.0"37 GCC_BRANCH="15_2_0-helenos" 38 GCC_VERSION="15.2" 42 39 43 40 BASEDIR="$PWD" 44 41 SRCDIR="$(readlink -f $(dirname "$0"))" 45 42 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 for 45 # all files, and we also have a ready-made package for distribution. 46 INSTALL_DIR="${BASEDIR}/PKG" 47 46 48 SYSTEM_INSTALL=false 47 REAL_INSTALL=true 48 USE_HELENOS_TARGET=true 49 50 BUILD_BINUTILS=true 51 BUILD_GCC=true 52 53 if [ -z "$JOBS" ] ; then 54 JOBS="`nproc`" 55 fi 49 56 50 57 check_error() { … … 61 68 echo 62 69 echo "Syntax:" 63 echo " $0 [--system-wide] [--no-install] [--non-helenos-target] <platform>"64 70 echo " $0 [--system-wide] --test-version [<platform>]" 65 71 echo … … 76 82 echo " sparc64 SPARC V9" 77 83 echo " all build all targets" 78 echo " essential build only targets currently needed for HelenOS development"79 84 echo " parallel same as 'all', but all in parallel" 80 85 echo " 2-way same as 'all', but 2-way parallel" … … 92 97 echo " variable is not set, then the default value of \$HOME/.local/share" 93 98 echo " is assumed." 94 echo95 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."101 99 echo 102 100 echo "The --non-helenos-target option will build non-HelenOS-specific" … … 139 137 for PLATFORM in $PLATFORMS ; do 140 138 set_target_from_platform "$PLATFORM" 141 PREFIX="${CROSS_PREFIX}/bin/${ HELENOS_TARGET}"139 PREFIX="${CROSS_PREFIX}/bin/${TARGET}" 142 140 143 141 echo "== $PLATFORM ==" 144 142 test_app_version "Binutils" "ld" "GNU ld (.*) \([.0-9]*\)" "$BINUTILS_VERSION" 145 143 test_app_version "GCC" "gcc" "gcc version \([.0-9]*\)" "$GCC_VERSION" 146 test_app_version "GDB" "gdb" "GNU gdb (.*)[[:space:]]\+\([.0-9]*\)" "$GDB_VERSION"147 144 done 148 145 } … … 177 174 } 178 175 176 ring_bell() { 177 printf '\a' 178 sleep 0.1 179 printf '\a' 180 sleep 0.1 181 printf '\a' 182 sleep 0.1 183 printf '\a' 184 sleep 0.1 185 printf '\a' 186 } 187 179 188 show_countdown() { 180 189 TM="$1" … … 241 250 242 251 check_dirs() { 243 OUTSIDE="$1" 244 BASE="$2" 245 ORIGINAL="$PWD" 246 247 cd "${BASE}" 248 check_error $? "Unable to change directory to ${BASE}." 252 cd "${BASEDIR}" 253 check_error $? "Unable to change directory to ${BASEDIR}." 249 254 ABS_BASE="$PWD" 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}." 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}." 256 265 257 266 while [ "${#PWD}" -gt "${#ABS_BASE}" ]; do … … 266 275 fi 267 276 268 cd "${ORIGINAL}" 269 check_error $? "Unable to change directory to ${ORIGINAL}." 277 cd "${BASEDIR}" 270 278 } 271 279 … … 280 288 change_title "Downloading sources" 281 289 echo ">>> Downloading sources" 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 .. 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 296 314 } 297 315 … … 321 339 esac 322 340 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 341 TARGET="${GNU_ARCH}-helenos" 342 } 343 344 build_binutils() { 345 # This sets the TARGET variable 346 set_target_from_platform "$1" 345 347 346 348 WORKDIR="${BASEDIR}/${TARGET}" 347 INSTALL_DIR="${BASEDIR}/PKG"348 349 BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}" 349 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"350 GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"351 352 # This sets the CROSS_PREFIX variable353 set_cross_prefix354 355 if [ -z "$JOBS" ] ; then356 JOBS="`nproc`"357 fi358 359 PREFIX="${CROSS_PREFIX}"360 350 361 351 echo ">>> Removing previous content" 362 352 cleanup_dir "${WORKDIR}" 363 353 mkdir -p "${WORKDIR}" 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})" 354 355 echo ">>> Processing binutils (${TARGET})" 385 356 mkdir -p "${BINUTILSDIR}" 386 357 cd "${BINUTILSDIR}" 387 358 check_error $? "Change directory failed." 388 359 389 change_title "binutils: configure (${ PLATFORM})"360 change_title "binutils: configure (${TARGET})" 390 361 CFLAGS="-Wno-error -fcommon" "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \ 391 362 "--target=${TARGET}" \ 392 "--prefix=${ PREFIX}" \363 "--prefix=${CROSS_PREFIX}" \ 393 364 "--program-prefix=${TARGET}-" \ 394 365 --disable-nls \ 395 366 --disable-werror \ 396 -- enable-gold \367 --disable-gold \ 397 368 --enable-deterministic-archives \ 398 369 --disable-gdb \ … … 400 371 check_error $? "Error configuring binutils." 401 372 402 change_title "binutils: make (${ PLATFORM})"373 change_title "binutils: make (${TARGET})" 403 374 make all -j$JOBS 404 375 check_error $? "Error compiling binutils." 405 376 406 change_title "binutils: install (${ PLATFORM})"407 make install "DESTDIR=${INSTALL_DIR}"377 change_title "binutils: install (${TARGET})" 378 make install $DESTDIR_SPEC 408 379 check_error $? "Error installing binutils." 409 410 411 echo ">>> Processing GCC (${PLATFORM})" 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})" 412 394 mkdir -p "${GCCDIR}" 413 395 cd "${GCCDIR}" 414 396 check_error $? "Change directory failed." 415 397 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" \ 398 BUILDPATH="${CROSS_PREFIX}/bin:${PATH}" 399 400 change_title "GCC: configure (${TARGET})" 401 PATH="${BUILDPATH}" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \ 424 402 "--target=${TARGET}" \ 425 "--prefix=${ PREFIX}" \403 "--prefix=${CROSS_PREFIX}" \ 426 404 "--program-prefix=${TARGET}-" \ 427 405 --with-gnu-as \ … … 430 408 --enable-languages=c,c++,go \ 431 409 --enable-lto \ 410 --enable-obsolete \ 432 411 --disable-shared \ 433 412 --disable-werror \ 434 $SYSROOT413 --without-headers # TODO: Replace with proper sysroot so we can build more libs 435 414 check_error $? "Error configuring GCC." 436 415 437 change_title "GCC: make (${ PLATFORM})"438 PATH="${ PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS416 change_title "GCC: make (${TARGET})" 417 PATH="${BUILDPATH}" make all-gcc -j$JOBS 439 418 check_error $? "Error compiling GCC." 440 419 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 420 change_title "GCC: install (${TARGET})" 421 PATH="${BUILDPATH}" make install-gcc $DESTDIR_SPEC 458 422 check_error $? "Error installing GCC." 459 460 461 echo ">>> Processing GDB (${PLATFORM})" 462 mkdir -p "${GDBDIR}" 463 cd "${GDBDIR}" 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}" 464 435 check_error $? "Change directory failed." 465 436 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 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() { 482 468 # Symlink clang and lld to the install path. 483 469 CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`" 470 CLANGPP="`which clang++ 2> /dev/null || echo "/usr/bin/clang++"`" 484 471 LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`" 485 472 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." 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" 502 476 } 503 477 … … 512 486 exit 513 487 ;; 514 --no-install)515 REAL_INSTALL=false516 shift517 ;;518 --non-helenos-target)519 USE_HELENOS_TARGET=false520 shift521 ;;522 488 *) 523 489 show_usage … … 529 495 show_usage 530 496 fi 497 498 PLATFORMS="amd64 arm32 arm64 ia32 ia64 mips32 mips32eb ppc32 riscv64 sparc64" 499 500 run_one() { 501 $1 $PLATFORM 502 } 503 504 run_all() { 505 for x in $PLATFORMS ; do 506 $1 $x 507 done 508 } 509 510 run_parallel() { 511 for x in $PLATFORMS ; do 512 $1 $x & 513 done 514 wait 515 } 516 517 run_2way() { 518 $1 amd64 & 519 $1 arm32 & 520 wait 521 522 $1 arm64 & 523 $1 ia32 & 524 wait 525 526 $1 ia64 & 527 $1 mips32 & 528 wait 529 530 $1 mips32eb & 531 $1 ppc32 & 532 wait 533 534 $1 riscv64 & 535 $1 sparc64 & 536 wait 537 } 538 539 everything() { 540 RUNNER="$1" 541 542 prepare 543 544 if $BUILD_BINUTILS ; then 545 $RUNNER build_binutils 546 547 if $BUILD_GCC ; then 548 # gcc/libgcc may fail to build correctly if binutils is not installed first 549 echo ">>> Installing binutils" 550 install_pkg 551 fi 552 fi 553 554 if $BUILD_GCC ; then 555 $RUNNER build_gcc 556 557 # libgcc may fail to build correctly if gcc is not installed first 558 echo ">>> Installing GCC" 559 install_pkg 560 561 $RUNNER build_libgcc 562 fi 563 564 echo ">>> Installing all files" 565 install_pkg 566 567 link_clang 568 } 531 569 532 570 case "$1" in … … 536 574 ;; 537 575 amd64|arm32|arm64|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64) 538 prepare539 build_target "$1"576 PLATFORM="$1" 577 everything run_one 540 578 ;; 541 579 "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" 580 everything run_all 565 581 ;; 566 582 "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 583 everything run_parallel 579 584 ;; 580 585 "2-way") 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 586 everything run_2way 601 587 ;; 602 588 *)
Note:
See TracChangeset
for help on using the changeset viewer.
