Changeset 5113


Ignore:
Timestamp:
Feb 10, 2010 9:31:38 PM (3 years ago)
Author:
oxygene
Message:

Improve compiler detection and configuration in xcompile.
Move -fno-stack-protector support from Makefile to xcompile.

Signed-off-by: Patrick Georgi <patrick.georgi@…>
Acked-by: Stefan Reinauer <stepan@…>

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    r5110 r5113  
    222222INCLUDES += -include $(obj)/build.h 
    223223 
    224 try-run= $(shell set -e; \ 
    225 TMP=".$$$$.tmp"; \ 
    226 if ($(1)) > /dev/null 2>&1; \ 
    227 then echo "$(2)"; \ 
    228 else echo "$(3)"; \ 
    229 fi; rm -rf "$$TMP") 
    230  
    231 cc-option= $(call try-run,\ 
    232 $(CC) $(1) -S -xc /dev/null -o "$$TMP", $(1), $(2)) 
    233  
    234 STACKPROTECT += $(call cc-option, -fno-stack-protector,) 
    235  
    236 CFLAGS = $(STACKPROTECT) $(INCLUDES) -Os -nostdinc 
     224CFLAGS = $(INCLUDES) -Os -nostdinc 
    237225CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes 
    238226CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs  
  • trunk/util/xcompile/xcompile

    r4952 r5113  
     1#!/bin/sh 
     2# 
     3# This file is part of the coreboot project. 
     4# 
     5# Copyright (C) 2007-2010 coresystems GmbH 
     6# 
     7# This program is free software; you can redistribute it and/or modify 
     8# it under the terms of the GNU General Public License version 2 as 
     9# published by the Free Software Foundation. 
     10# 
     11# This program is distributed in the hope that it will be useful, 
     12# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     14# GNU General Public License for more details. 
     15# 
     16# You should have received a copy of the GNU General Public License 
     17# along with this program; if not, write to the Free Software 
     18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA 
     19# 
     20 
     21testcc() 
     22{ 
     23        echo "_start(void) {}" > .$$$$.c 
     24        $1 -nostdlib $2 .$$$$.c -o .$$$$.tmp 2>/dev/null >/dev/null 
     25        ret=$? 
     26        rm -f .$$$$.c .$$$$.tmp 
     27        return $ret 
     28} 
    129 
    230for make in make gmake gnumake; do 
     
    937GCCPREFIX=invalid 
    1038TMP=`mktemp /tmp/temp.XXXX 2>/dev/null || echo /tmp/temp.78gOIUGz` 
    11 echo "mov %eax, %eax" > ${TMP}.s 
    12 printf "\x7fELF\n" > ${TMP}.compare 
    13 for gccprefixes in `pwd`/util/crossgcc/xgcc/bin/i386-elf- i386-elf- ""; do 
    14         if which ${gccprefixes}as 2>/dev/null >/dev/null; then 
    15                 printf "" 
    16         else 
     39touch $TMP 
     40 
     41# This should be a loop over all supported architectures 
     42TARCH=i386 
     43TWIDTH=32 
     44for gccprefixes in `pwd`/util/crossgcc/xgcc/bin/${TARCH}-elf- ${TARCH}-elf- ""; do 
     45        if ! which ${gccprefixes}as 2>/dev/null >/dev/null; then 
    1746                continue 
    1847        fi 
    1948        rm -f ${TMP}.o 
    20         if ${gccprefixes}as --32 -o ${TMP}.o ${TMP}.s; then 
    21                 cut -c-4 ${TMP}.o > ${TMP}.test 2>/dev/null 
    22                 if cmp ${TMP}.test ${TMP}.compare; then 
     49        if ${gccprefixes}as -o ${TMP}.o ${TMP}; then 
     50                TYPE=`${gccprefixes}objdump -p ${TMP}.o` 
     51                if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then 
    2352                        GCCPREFIX=$gccprefixes 
     53                        ASFLAGS= 
     54                        CFLAGS= 
     55                        LDFLAGS= 
     56                        break 
     57                fi 
     58        fi 
     59        if ${gccprefixes}as --32 -o ${TMP}.o ${TMP}; then 
     60                TYPE=`${gccprefixes}objdump -p ${TMP}.o` 
     61                if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then 
     62                        GCCPREFIX=$gccprefixes 
     63                        ASFLAGS=--32 
     64                        CFLAGS="-m32 " 
     65                        LDFLAGS="-b elf32-i386" 
    2466                        break 
    2567                fi 
    2668        fi 
    2769done 
    28 rm -f $TMP ${TMP}.s ${TMP}.o ${TMP}.compare ${TMP}.test 
     70rm -f $TMP ${TMP}.o 
    2971 
    3072if [ "$GCCPREFIX" = "invalid" ]; then 
     
    3375fi 
    3476 
    35 cat << afteroptions 
    36 AS:=${GCCPREFIX}as --32 
    37 CC:=${GCCPREFIX}gcc -m32 
     77CC="${GCCPREFIX}gcc" 
     78testcc "$CC" "$CFLAGS-fno-stack-protector " && CFLAGS="$CFLAGS-fno-stack-protector " 
     79testcc "$CC" "$CFLAGS-Wl,--build-id=none " && CFLAGS="$CFLAGS-Wl,--build-id=none " 
     80 
     81if which gcc 2>/dev/null >/dev/null; then 
     82        HOSTCC=gcc 
     83else 
     84        HOSTCC=cc 
     85fi 
     86 
     87cat << EOF 
     88# elf${TWIDTH}-${TARCH} toolchain 
     89AS:=${GCCPREFIX}as ${ASFLAGS} 
     90CC:=${GCCPREFIX}gcc ${CFLAGS} 
    3891CPP:=${GCCPREFIX}cpp 
    3992AR:=${GCCPREFIX}ar 
    40 LD:=${GCCPREFIX}ld -b elf32-i386 
     93LD:=${GCCPREFIX}ld ${LDFLAGS} 
    4194STRIP:=${GCCPREFIX}strip 
    4295NM:=${GCCPREFIX}nm 
    4396OBJCOPY:=${GCCPREFIX}objcopy 
    4497OBJDUMP:=${GCCPREFIX}objdump 
    45 HOSTCC:=gcc 
    46 afteroptions 
     98 
     99# native toolchain 
     100HOSTCC:=${HOSTCC} 
     101EOF 
     102 
Note: See TracChangeset for help on using the changeset viewer.