Changeset 2431f30 in mainline


Ignore:
Timestamp:
2011-06-13T01:32:54Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c1198c2
Parents:
df56f5c
Message:

Build process debugged and improved.
Added intrusive patches to pass configure scripts.

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rdf56f5c r2431f30  
    100100distclean: clean
    101101        rm -f $(CSCOPE).out $(COMMON_MAKEFILE) $(COMMON_HEADER) $(COMMON_HEADER_PREV) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) tools/*.pyc tools/checkers/*.pyc release/HelenOS-*
     102        cd ./uspace/app/binutils/; ./distclean.sh
    102103
    103104clean:
  • uspace/app/binutils/Makefile

    rdf56f5c r2431f30  
    4646# because targets derived from it will be referenced from
    4747# other than the current directory.
    48 USPACE_PREFIX = $(subst $(space),\ ,$(PWD))/../..
     48USPACE_PREFIX = $(subst $(space),\ ,$(shell pwd))/../..
    4949
    5050# Ensure static configuration of Makefile.common.
     
    7070
    7171# Patch $PATH to intercept toolchain calls.
    72 PATH := $(PWD):$(PATH)
     72PATH := $(shell pwd):$(PATH)
     73export PATH
    7374
    7475# Shell script for false toolchain generation.
     
    8990# Map the HelenOS target to binutils target.
    9091ifeq ($(PLATFORM),amd64)
    91 TARGET=amd64-linux-gnu
    92 else ($(PLATFORM),arm32)
    93 TARGET=arm-linux-gnu
    94 else ($(PLATFORM),ia32)
    95 TARGET=i686-pc-linux-gnu
    96 else ($(PLATFORM),ia64)
    97 TARGET=ia64-pc-linux-gnu
    98 else ($(PLATFORM),mips32)
    99 TARGET=mipsel-linux-gnu
    100 else ($(PLATFORM),mips32eb)
    101 TARGET=mips-linux-gnu
    102 else ($(PLATFORM),mips64)
    103 TARGET=mips64el-linux-gnu
    104 else ($(PLATFORM),ppc32)
    105 TARGET=ppc-linux-gnu
    106 else ($(PLATFORM),ppc64)
    107 TARGET=ppc64-linux-gnu
    108 else ($(PLATFORM),sparc64)
    109 TARGET=sparc64-linux-gnu
     92TARGET = amd64-linux-gnu
     93endif
     94ifeq ($(PLATFORM),arm32)
     95TARGET = arm-linux-gnu
     96endif
     97ifeq ($(PLATFORM),ia32)
     98TARGET = i686-pc-linux-gnu
     99endif
     100ifeq ($(PLATFORM),ia64)
     101TARGET = ia64-pc-linux-gnu
     102endif
     103ifeq ($(PLATFORM),mips32)
     104TARGET = mipsel-linux-gnu
     105endif
     106ifeq ($(PLATFORM),mips32eb)
     107TARGET = mips-linux-gnu
     108endif
     109ifeq ($(PLATFORM),mips64)
     110TARGET = mips64el-linux-gnu
     111endif
     112ifeq ($(PLATFORM),ppc32)
     113TARGET = ppc-linux-gnu
     114endif
     115ifeq ($(PLATFORM),ppc64)
     116TARGET = ppc64-linux-gnu
     117endif
     118ifeq ($(PLATFORM),sparc64)
     119TARGET = sparc64-linux-gnu
    110120endif
    111121
    112122# Binutils configure flags.
    113123CONF_FLAGS = --disable-nls --disable-shared --enable-static \
    114         --with-zlib=no
     124        --with-zlib=no --with-ppl=no --with-cloog=no  \
     125        --with-gmp=no --with-mpfr=no --with-mpc=no
    115126
    116127# Binutils make targets.
     
    123134all: $(COMMON_MAKEFILE_PATCHED) all_ $(TOOLCHAIN) $(BINUTILS_PATCHED) \
    124135                $(BINUTILS_CONFIGURED) $(REDIST_DETECT)
    125         export PATH
    126136        make -C $(REDIST_DIR) $(MAKE_TARGETS)
    127137        cp -f $(REDIST_DIR)/gas/as-new ./as
     
    143153$(REDIST_DETECT): $(REDIST_FILENAME)
    144154        tar -x -j -f $<
    145         mv -f $(REDIST_NAME) $(REDIST_DIR)
     155        mv -f -T $(REDIST_NAME) $(REDIST_DIR)
     156        touch $@
    146157
    147158# Generate false toolchain scripts.
    148159$(TOOLCHAIN): $(TOOLCHAIN_SCRIPT)
    149         $^ gcc $(CC) '$(CFLAGS)'
    150         $^ as $(AS)
    151         $^ ar $(AR)
    152         $^ ranlib
    153         $^ ld $(LD) '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
    154         $^ objdump $(OBJDUMP)
    155         $^ objcopy $(OBJCOPY)
    156         $^ strip $(STRIP)
     160        ./$< gcc $(CC) '$(CFLAGS)'
     161        ./$< as $(AS)
     162        ./$< ar $(AR)
     163        ./$< ranlib
     164        ./$< ld $(LD) '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
     165        ./$< objdump $(OBJDUMP)
     166        ./$< objcopy $(OBJCOPY)
     167        ./$< strip $(STRIP)
    157168
    158169# Patch binutils source tree.
    159170$(BINUTILS_PATCHED): $(BINUTILS_PATCH) $(REDIST_DETECT)
    160         $^ do $(REDIST_DIR)
     171        ./$< do $(REDIST_DIR)
    161172        touch $@
    162173
    163174# Configure binutils.
     175# $LD variable have to exported to override configure script caching.
    164176$(BINUTILS_CONFIGURED): $(REDIST_DIR)/configure $(REDIST_DETECT)
    165         $^ --target=$(TARGET) $(CONF_FLAGS)
     177        export LD=ld; \
     178        cd $(REDIST_DIR); \
     179        ./configure --target=$(TARGET) $(CONF_FLAGS)
    166180
    167181# Delete binaries.
     
    169183# Unpatch binutils.
    170184# Delete generated scripts.
    171 clean: $(BINUTILS_PATCH)
     185clean: $(BINUTILS_PATCH) clean_
    172186        rm -f as ld
    173         if [ -e $(REDIST_DIR)/Makefile ]; then
    174                 make -C $(REDIST_DIR) distclean
     187        if [ -e $(REDIST_DIR)/Makefile ]; then \
     188                make -C $(REDIST_DIR) distclean; \
    175189        fi
    176         if [ -e $(BINUTILS_PATCHED) ]; then
    177                 ./intrusive.sh undo $(REDIST_DIR)
    178                 rm -f $(BINUTILS_PATCHED)
     190        if [ -e $(BINUTILS_PATCHED) ]; then \
     191                ./intrusive.sh undo $(REDIST_DIR); \
     192                rm -f $(BINUTILS_PATCHED); \
    179193        fi
    180194        rm -f $(TOOLCHAIN)
  • uspace/app/binutils/intrusive.sh

    rdf56f5c r2431f30  
    3434# would require too much complexity.
    3535#
     36# List of patch descriptions:
     37#
     38# Patch 1
     39# Even though binutils build process supports cross compilation where
     40# build and host platforms are different, it is not easily applicable
     41# to HelenOS. It would be difficult to satisfy binutils expectations
     42# of host headers, libraries and tools on a build system (at least
     43# until these are developed/ported). Another issue would be the
     44# necessity to carry out time consuming full canadian cross compilation
     45# (even in case when build, host and target hardware platforms are the
     46# same). Instead of going into such trouble, it is easier to leverage
     47# already  built HelenOS toolchain as a first stage of canadian cross
     48# and trick binutils scripts to do a simple cross compilation while
     49# actually doing second stage of canadian cross. Because binutils
     50# configure scripts try to compile and execute various testing code, it
     51# have to be ensured that these tests are skipped. Such behaviour can
     52# be acomplished by patching cross compilation flag while leaving host
     53# and build parameters empty (i.e. configure script believes it is
     54# not doing cross compilation while skipping some testing as in the case
     55# of cross compilation).
     56#
     57# Patch 2
     58# Enabled cross compilation flag brings along some anomalies which
     59# have to reverted.
     60#
     61# Patch 3
     62# Binutils plugin support is dependent on libdl.so library.
     63# By default, the plugin support is switched off for all
     64# configure scripts of binutils. The only exception is configure
     65# script of ld 2.21 (and possibly above), where plugin support
     66# became mandatory (although not really needed).
     67#
    3668
    3769case "$1" in
    3870        "do")
    39                 # Binutils plugin support is dependent on libdl.so library.
    40                 # By default, the plugin support is switched off for all
    41                 # configure scripts of binutils. The only exception is configure
    42                 # script of ld 2.21 (and possibly above), where plugin support
    43                 # became mandatory (although not really needed).
    44                 mv -f "$2/ld/configure" "$2/ld/configure.backup"
    45                 sed 's/enable_plugins=yes/enable_plugins=no/g' \
    46                         < "$2/ld/configure.backup" > "$2/ld/configure"
     71                # Backup original files.
     72                cp -f "$2/configure" "$2/configure.backup"
     73                cp -f "$2/bfd/configure" "$2/bfd/configure.backup"
     74                cp -f "$2/gas/configure" "$2/gas/configure.backup"
     75                cp -f "$2/intl/configure" "$2/intl/configure.backup"
     76                cp -f "$2/ld/configure" "$2/ld/configure.backup"
     77                cp -f "$2/libiberty/configure" "$2/libiberty/configure.backup"
     78                cp -f "$2/opcodes/configure" "$2/opcodes/configure.backup"
     79
     80                # Patch main binutils configure script.
     81                cat "$2/configure.backup" | \
     82                # See Patch 1.
     83                sed 's/^cross_compiling=no/cross_compiling=yes/g' \
     84                > "$2/configure"
     85
     86                # Patch bfd configure script.
     87                cat "$2/bfd/configure.backup" | \
     88                # See Patch 1.
     89                sed 's/^cross_compiling=no/cross_compiling=yes/g' \
     90                > "$2/bfd/configure"
     91
     92                # Patch gas configure script.
     93                cat "$2/gas/configure.backup" | \
     94                # See Patch 1.
     95                sed 's/^cross_compiling=no/cross_compiling=yes/g' \
     96                > "$2/gas/configure"
     97
     98                # Patch intl configure script.
     99                cat "$2/intl/configure.backup" | \
     100                # See Patch 1.
     101                sed 's/^cross_compiling=no/cross_compiling=yes/g' \
     102                > "$2/intl/configure"
     103
     104                # Patch ld configure script.
     105                cat "$2/ld/configure.backup" | \
     106                # See Patch 1.
     107                sed 's/^cross_compiling=no/cross_compiling=yes/g' | \
     108                # See Patch 3.
     109                sed 's/^enable_plugins=yes/enable_plugins=no/g' \
     110                > "$2/ld/configure"
     111
     112                # Patch libiberty configure script.
     113                cat "$2/libiberty/configure.backup" | \
     114                # See Patch 1.
     115                sed 's/^cross_compiling=no/cross_compiling=yes/g' \
     116                > "$2/libiberty/configure"
     117
     118                # Patch opcodes configure script.
     119                cat "$2/opcodes/configure.backup" | \
     120                # See Patch 1.
     121                sed 's/^cross_compiling=no/cross_compiling=yes/g' | \
     122                # See Patch 2.
     123                sed 's/BUILD_LIBS=-liberty/BUILD_LIBS=..\/libiberty\/libiberty.a/g' \
     124                > "$2/opcodes/configure"
     125
    47126                ;;
    48127        "undo")
     128                # Restore original files.
     129                mv -f "$2/configure.backup" "$2/configure"
     130                mv -f "$2/bfd/configure.backup" "$2/bfd/configure"
     131                mv -f "$2/gas/configure.backup" "$2/gas/configure"
     132                mv -f "$2/intl/configure.backup" "$2/intl/configure"
    49133                mv -f "$2/ld/configure.backup" "$2/ld/configure"
     134                mv -f "$2/libiberty/configure.backup" "$2/libiberty/configure"
     135                mv -f "$2/opcodes/configure.backup" "$2/opcodes/configure"
    50136                ;;
    51137        *)
  • uspace/app/binutils/toolchain.sh

    rdf56f5c r2431f30  
    7575                        sed 's/-W[^ ]*//g' | \
    7676                        sed 's/-pipe//g' | \
    77                         sed 's/-std=[^ ]*//g' | \
    7877                        sed 's/-g//g' | \
    7978                        sed 's/ [ ]*/ /g'`"
     79                echo '  echo' \'"$2"\' \'"$CFLAGS"\' '"$@"'
    8080                echo "  $2" "$CFLAGS" '$@'
    8181                echo 'fi'
     
    8686                (
    8787                echo '#! /bin/bash'
     88                echo 'echo' \'"$2"\' '"$@"'
    8889                echo "$2" '$@'
    8990                ) > 'as'
     
    9394                (
    9495                echo '#! /bin/bash'
     96                echo 'echo' \'"$2"\' '"$@"'
    9597                echo "$2" '$@'
    9698                ) > 'ar'
     
    100102                (
    101103                echo '#! /bin/bash'
     104                echo 'echo' \'"$2"\' '"$@"'
    102105                echo "ar -s" '$@'
    103106                ) > 'ranlib'
     
    107110                (
    108111                echo '#! /bin/bash'
     112                echo 'echo' \'"$2 -n $3 -T $4"\' '"$@"' \'"$5"\'
    109113                echo "$2 -n $3 -T $4" '$@' "$5"
    110114                ) > 'ld'
     
    114118                (
    115119                echo '#! /bin/bash'
     120                echo 'echo' \'"$2"\' '"$@"'
    116121                echo "$2" '$@'
    117122                ) > 'objdump'
     
    121126                (
    122127                echo '#! /bin/bash'
     128                echo 'echo' \'"$2"\' '"$@"'
    123129                echo "$2" '$@'
    124130                ) > 'objcopy'
     
    128134                (
    129135                echo '#! /bin/bash'
     136                echo 'echo' \'"$2"\' '"$@"'
    130137                echo "$2" '$@'
    131138                ) > 'strip'
Note: See TracChangeset for help on using the changeset viewer.