Changes in tools/toolchain.sh [f3a7b0d:56210a7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/toolchain.sh
rf3a7b0d r56210a7 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_43-helenos" 34 BINUTILS_VERSION="2.43" 35 36 GDB_BRANCH="gdb-13.2-helenos" 37 GDB_VERSION="13.2" 38 38 39 39 GCC_GIT="https://github.com/HelenOS/gcc.git" 40 GCC_BRANCH=" 8_2_0-helenos"41 GCC_VERSION=" 8.2.0"40 GCC_BRANCH="14_2_0-helenos" 41 GCC_VERSION="14.2" 42 42 43 43 BASEDIR="$PWD" 44 44 SRCDIR="$(readlink -f $(dirname "$0"))" 45 45 46 # If we install into a temporary directory and copy from there, 47 # we don't have to trust the upstream makefiles respect the prefix for 48 # all files, and we also have a ready-made package for distribution. 49 INSTALL_DIR="${BASEDIR}/PKG" 50 46 51 SYSTEM_INSTALL=false 47 REAL_INSTALL=true 48 USE_HELENOS_TARGET=true 52 53 BUILD_GDB=false 54 BUILD_BINUTILS=true 55 BUILD_GCC=true 56 57 if [ -z "$JOBS" ] ; then 58 JOBS="`nproc`" 59 fi 49 60 50 61 check_error() { … … 61 72 echo 62 73 echo "Syntax:" 63 echo " $0 [--system-wide] [-- no-install] [--non-helenos-target] <platform>"74 echo " $0 [--system-wide] [--with-gdb|--only-gdb] <platform>" 64 75 echo " $0 [--system-wide] --test-version [<platform>]" 65 76 echo … … 76 87 echo " sparc64 SPARC V9" 77 88 echo " all build all targets" 78 echo " essential build only targets currently needed for HelenOS development"79 89 echo " parallel same as 'all', but all in parallel" 80 90 echo " 2-way same as 'all', but 2-way parallel" … … 92 102 echo " variable is not set, then the default value of \$HOME/.local/share" 93 103 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 104 echo 102 105 echo "The --non-helenos-target option will build non-HelenOS-specific" … … 139 142 for PLATFORM in $PLATFORMS ; do 140 143 set_target_from_platform "$PLATFORM" 141 PREFIX="${CROSS_PREFIX}/bin/${ HELENOS_TARGET}"144 PREFIX="${CROSS_PREFIX}/bin/${TARGET}" 142 145 143 146 echo "== $PLATFORM ==" … … 177 180 } 178 181 182 ring_bell() { 183 printf '\a' 184 sleep 0.1 185 printf '\a' 186 sleep 0.1 187 printf '\a' 188 sleep 0.1 189 printf '\a' 190 sleep 0.1 191 printf '\a' 192 } 193 179 194 show_countdown() { 180 195 TM="$1" … … 241 256 242 257 check_dirs() { 243 OUTSIDE="$1" 244 BASE="$2" 245 ORIGINAL="$PWD" 246 247 cd "${BASE}" 248 check_error $? "Unable to change directory to ${BASE}." 258 cd "${BASEDIR}" 259 check_error $? "Unable to change directory to ${BASEDIR}." 249 260 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}." 261 262 if $SYSTEM_INSTALL && [ ! -d "${CROSS_PREFIX}" ]; then 263 ring_bell 264 ( set -x ; sudo -k mkdir -p "${CROSS_PREFIX}" ) 265 else 266 mkdir -p "${CROSS_PREFIX}" 267 fi 268 269 cd "${CROSS_PREFIX}" 270 check_error $? "Unable to change directory to ${CROSS_PREFIX}." 256 271 257 272 while [ "${#PWD}" -gt "${#ABS_BASE}" ]; do … … 266 281 fi 267 282 268 cd "${ORIGINAL}" 269 check_error $? "Unable to change directory to ${ORIGINAL}." 283 cd "${BASEDIR}" 270 284 } 271 285 … … 280 294 change_title "Downloading sources" 281 295 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 .. 296 297 if $BUILD_BINUTILS ; then 298 git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION" 299 # If the directory already existed, pull upstream changes. 300 git -C "binutils-$BINUTILS_VERSION" pull 301 fi 302 303 if $BUILD_GCC ; then 304 git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION" 305 git -C "gcc-$GCC_VERSION" pull 306 307 change_title "Downloading GCC prerequisites" 308 echo ">>> Downloading GCC prerequisites" 309 cd "gcc-${GCC_VERSION}" 310 ./contrib/download_prerequisites 311 cd .. 312 fi 313 314 if $BUILD_GDB ; then 315 git clone --depth 1 -b "$GDB_BRANCH" "$BINUTILS_GDB_GIT" "gdb-$GDB_VERSION" 316 git -C "gdb-$GDB_VERSION" pull 317 fi 318 319 # This sets the CROSS_PREFIX variable 320 set_cross_prefix 321 322 DESTDIR_SPEC="DESTDIR=${INSTALL_DIR}" 323 324 check_dirs 296 325 } 297 326 … … 321 350 esac 322 351 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 352 TARGET="${GNU_ARCH}-helenos" 353 } 354 355 build_binutils() { 356 # This sets the TARGET variable 357 set_target_from_platform "$1" 345 358 346 359 WORKDIR="${BASEDIR}/${TARGET}" 347 INSTALL_DIR="${BASEDIR}/PKG"348 360 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 361 361 362 echo ">>> Removing previous content" 362 363 cleanup_dir "${WORKDIR}" 363 364 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})" 365 366 echo ">>> Processing binutils (${TARGET})" 385 367 mkdir -p "${BINUTILSDIR}" 386 368 cd "${BINUTILSDIR}" 387 369 check_error $? "Change directory failed." 388 370 389 change_title "binutils: configure (${ PLATFORM})"371 change_title "binutils: configure (${TARGET})" 390 372 CFLAGS="-Wno-error -fcommon" "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \ 391 373 "--target=${TARGET}" \ 392 "--prefix=${ PREFIX}" \374 "--prefix=${CROSS_PREFIX}" \ 393 375 "--program-prefix=${TARGET}-" \ 394 376 --disable-nls \ … … 400 382 check_error $? "Error configuring binutils." 401 383 402 change_title "binutils: make (${ PLATFORM})"384 change_title "binutils: make (${TARGET})" 403 385 make all -j$JOBS 404 386 check_error $? "Error compiling binutils." 405 387 406 change_title "binutils: install (${ PLATFORM})"407 make install "DESTDIR=${INSTALL_DIR}"388 change_title "binutils: install (${TARGET})" 389 make install $DESTDIR_SPEC 408 390 check_error $? "Error installing binutils." 409 410 411 echo ">>> Processing GCC (${PLATFORM})" 391 } 392 393 build_gcc() { 394 # This sets the TARGET variable 395 set_target_from_platform "$1" 396 397 WORKDIR="${BASEDIR}/${TARGET}" 398 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" 399 400 echo ">>> Removing previous content" 401 cleanup_dir "${WORKDIR}" 402 mkdir -p "${WORKDIR}" 403 404 echo ">>> Processing GCC (${TARGET})" 412 405 mkdir -p "${GCCDIR}" 413 406 cd "${GCCDIR}" 414 407 check_error $? "Change directory failed." 415 408 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" \ 409 BUILDPATH="${CROSS_PREFIX}/bin:${PATH}" 410 411 change_title "GCC: configure (${TARGET})" 412 PATH="${BUILDPATH}" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \ 424 413 "--target=${TARGET}" \ 425 "--prefix=${ PREFIX}" \414 "--prefix=${CROSS_PREFIX}" \ 426 415 "--program-prefix=${TARGET}-" \ 427 416 --with-gnu-as \ … … 430 419 --enable-languages=c,c++,go \ 431 420 --enable-lto \ 421 --enable-obsolete \ 432 422 --disable-shared \ 433 423 --disable-werror \ 434 $SYSROOT424 --without-headers # TODO: Replace with proper sysroot so we can build more libs 435 425 check_error $? "Error configuring GCC." 436 426 437 change_title "GCC: make (${ PLATFORM})"438 PATH="${ PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS427 change_title "GCC: make (${TARGET})" 428 PATH="${BUILDPATH}" make all-gcc -j$JOBS 439 429 check_error $? "Error compiling GCC." 440 430 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 431 change_title "GCC: install (${TARGET})" 432 PATH="${BUILDPATH}" make install-gcc $DESTDIR_SPEC 458 433 check_error $? "Error installing GCC." 459 460 461 echo ">>> Processing GDB (${PLATFORM})" 434 } 435 436 build_libgcc() { 437 # This sets the TARGET variable 438 set_target_from_platform "$1" 439 440 WORKDIR="${BASEDIR}/${TARGET}" 441 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" 442 443 # No removing previous content here, we need the previous GCC build 444 445 cd "${GCCDIR}" 446 check_error $? "Change directory failed." 447 448 BUILDPATH="${CROSS_PREFIX}/bin:${PATH}" 449 450 change_title "libgcc: make (${TARGET})" 451 452 PATH="${BUILDPATH}" make all-target-libgcc -j$JOBS 453 check_error $? "Error compiling libgcc." 454 # TODO: libatomic and libstdc++ need some extra care 455 # PATH="${BUILDPATH}" make all-target-libatomic -j$JOBS 456 # check_error $? "Error compiling libatomic." 457 # PATH="${BUILDPATH}" make all-target-libstdc++-v3 -j$JOBS 458 # check_error $? "Error compiling libstdc++." 459 460 change_title "libgcc: install (${TARGET})" 461 462 PATH="${BUILDPATH}" make install-target-libgcc $DESTDIR_SPEC 463 # PATH="${BUILDPATH}" make install-target-libatomic $DESTDIR_SPEC 464 # PATH="${BUILDPATH}" make install-target-libstdc++-v3 $DESTDIR_SPEC 465 check_error $? "Error installing libgcc." 466 } 467 468 build_gdb() { 469 # This sets the TARGET variable 470 set_target_from_platform "$1" 471 472 WORKDIR="${BASEDIR}/${TARGET}" 473 GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}" 474 475 echo ">>> Removing previous content" 476 cleanup_dir "${WORKDIR}" 477 mkdir -p "${WORKDIR}" 478 479 echo ">>> Processing GDB (${TARGET})" 462 480 mkdir -p "${GDBDIR}" 463 481 cd "${GDBDIR}" 464 482 check_error $? "Change directory failed." 465 483 466 change_title "GDB: configure (${ PLATFORM})"467 CFLAGS="-fcommon" PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin""${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \484 change_title "GDB: configure (${TARGET})" 485 CFLAGS="-fcommon" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \ 468 486 "--target=${TARGET}" \ 469 "--prefix=${ PREFIX}" \487 "--prefix=${CROSS_PREFIX}" \ 470 488 "--program-prefix=${TARGET}-" \ 471 489 --enable-werror=no 472 490 check_error $? "Error configuring GDB." 473 491 474 change_title "GDB: make (${ PLATFORM})"475 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin"make all-gdb -j$JOBS492 change_title "GDB: make (${TARGET})" 493 make all-gdb -j$JOBS 476 494 check_error $? "Error compiling GDB." 477 495 478 change_title "GDB: make (${PLATFORM})"479 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gdb "DESTDIR=${INSTALL_DIR}"496 change_title "GDB: install (${TARGET})" 497 make install-gdb $DESTDIR_SPEC 480 498 check_error $? "Error installing GDB." 481 499 } 500 501 install_pkg() { 502 echo ">>> Moving to the destination directory." 503 if $SYSTEM_INSTALL ; then 504 ring_bell 505 ( set -x ; sudo -k cp -r -t "${CROSS_PREFIX}" "${INSTALL_DIR}${CROSS_PREFIX}/"* ) 506 else 507 ( set -x ; cp -r -t "${CROSS_PREFIX}" "${INSTALL_DIR}${CROSS_PREFIX}/"* ) 508 fi 509 } 510 511 link_clang() { 482 512 # Symlink clang and lld to the install path. 483 513 CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`" 484 514 LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`" 485 515 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." 516 ln -s $CLANG "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-clang" 517 ln -s $LLD "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-ld.lld" 502 518 } 503 519 … … 512 528 exit 513 529 ;; 514 -- no-install)515 REAL_INSTALL=false530 --with-gdb) 531 BUILD_GDB=true 516 532 shift 517 533 ;; 518 --non-helenos-target) 519 USE_HELENOS_TARGET=false 534 --only-gdb) 535 BUILD_GDB=true 536 BUILD_BINUTILS=false 537 BUILD_GCC=false 520 538 shift 521 539 ;; … … 529 547 show_usage 530 548 fi 549 550 PLATFORMS="amd64 arm32 arm64 ia32 ia64 mips32 mips32eb ppc32 riscv64 sparc64" 551 552 run_one() { 553 $1 $PLATFORM 554 } 555 556 run_all() { 557 for x in $PLATFORMS ; do 558 $1 $x 559 done 560 } 561 562 run_parallel() { 563 for x in $PLATFORMS ; do 564 $1 $x & 565 done 566 wait 567 } 568 569 run_2way() { 570 $1 amd64 & 571 $1 arm32 & 572 wait 573 574 $1 arm64 & 575 $1 ia32 & 576 wait 577 578 $1 ia64 & 579 $1 mips32 & 580 wait 581 582 $1 mips32eb & 583 $1 ppc32 & 584 wait 585 586 $1 riscv64 & 587 $1 sparc64 & 588 wait 589 } 590 591 everything() { 592 RUNNER="$1" 593 594 prepare 595 596 if $BUILD_BINUTILS ; then 597 $RUNNER build_binutils 598 599 if $BUILD_GCC ; then 600 # gcc/libgcc may fail to build correctly if binutils is not installed first 601 echo ">>> Installing binutils" 602 install_pkg 603 fi 604 fi 605 606 if $BUILD_GCC ; then 607 $RUNNER build_gcc 608 609 # libgcc may fail to build correctly if gcc is not installed first 610 echo ">>> Installing GCC" 611 install_pkg 612 613 $RUNNER build_libgcc 614 fi 615 616 if $BUILD_GDB ; then 617 $RUNNER build_gdb 618 fi 619 620 echo ">>> Installing all files" 621 install_pkg 622 623 link_clang 624 } 531 625 532 626 case "$1" in … … 536 630 ;; 537 631 amd64|arm32|arm64|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64) 538 prepare539 build_target "$1"632 PLATFORM="$1" 633 everything run_one 540 634 ;; 541 635 "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" 636 everything run_all 565 637 ;; 566 638 "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 639 everything run_parallel 579 640 ;; 580 641 "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 642 everything run_2way 601 643 ;; 602 644 *)
Note:
See TracChangeset
for help on using the changeset viewer.