Skip to content

Commit

Permalink
Noux: update GCC to version 4.6.1
Browse files Browse the repository at this point in the history
This patch updates GCC to version 4.6.1 and enables tool chain support for
x86_64 and ARM.

Fixes #266.
  • Loading branch information
cproc authored and nfeske committed Jul 4, 2012
1 parent 7a25bf2 commit e39200d
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 431 deletions.
2 changes: 1 addition & 1 deletion base/mk/spec-arm_v5.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ SPECS += arm
#
# Configure target CPU
#
CC_OPT += -march=armv5
CC_MARCH += -march=armv5

include $(call select_from_repositories,mk/spec-arm.mk)
2 changes: 1 addition & 1 deletion base/mk/spec-arm_v7a.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ SPECS += arm
#
# Configure target CPU
#
CC_OPT += -march=armv7-a
CC_MARCH += -march=armv7-a

include $(call select_from_repositories,mk/spec-arm.mk)
16 changes: 12 additions & 4 deletions ports/mk/noux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NOUX_PKG ?= $(TARGET)

LIBS += cxx env libc libm libc_noux

NOUX_PKG_DIR = $(wildcard $(REP_DIR)/contrib/$(NOUX_PKG)-*)
NOUX_PKG_DIR ?= $(wildcard $(REP_DIR)/contrib/$(NOUX_PKG)-*)

PWD = $(shell pwd)

Expand Down Expand Up @@ -68,8 +68,15 @@ NOUX_BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [$(NOUX_PKG)] /"

endif

ifeq ($(findstring arm, $(SPECS)), arm)
NOUX_CONFIGURE_ARGS += --host arm-elf-eabi
else
ifeq ($(findstring x86, $(SPECS)), x86)
NOUX_CONFIGURE_ARGS += --host x86_64-elf
endif
endif

NOUX_CONFIGURE_ARGS += --srcdir=$(NOUX_PKG_DIR)
NOUX_CONFIGURE_ARGS += --host x86-freebsd
NOUX_CONFIGURE_ARGS += --prefix $(PWD)/install

CONFIG_GUESS_SCRIPT = $(NOUX_PKG_DIR)/config.guess)
Expand Down Expand Up @@ -104,9 +111,9 @@ NOUX_LIBS_A = $(filter %.a, $(sort $(LINK_ITEMS)) $(EXT_OBJECTS) $(LIBGCC))
NOUX_LIBS_SO = $(filter %.so,$(sort $(LINK_ITEMS)) $(EXT_OBJECTS) $(LIBGCC))
NOUX_LIBS += $(NOUX_LIBS_A) $(NOUX_LIBS_SO) $(NOUX_LIBS_A)

NOUX_ENV += CC='$(CC)' LD='$(LD)' AR='$(AR)' STRIP='$(STRIP)' LIBS='$(NOUX_LIBS)' \
NOUX_ENV += CC='$(CC)' CXX='$(CXX)' LD='$(LD)' AR='$(AR)' STRIP='$(STRIP)' LIBS='$(NOUX_LIBS)' \
LDFLAGS='$(NOUX_LDFLAGS)' CFLAGS='$(NOUX_CFLAGS)' \
CPPFLAGS='$(NOUX_CPPFLAGS)'
CPPFLAGS='$(NOUX_CPPFLAGS)' CXXFLAGS='$(NOUX_CXXFLAGS)'

NOUX_ENV += CC_FOR_BUILD=gcc LD_FOR_BUILD=ld \
CFLAGS_FOR_BUILD='$(NOUX_CFLAGS_FOR_BUILD)' \
Expand All @@ -127,6 +134,7 @@ Makefile reconfigure: noux_env.sh
noux_env.sh:
$(VERBOSE)rm -f $@
$(VERBOSE)echo "export CC='$(CC)'" >> $@
$(VERBOSE)echo "export CXX='$(CXX)'" >> $@
$(VERBOSE)echo "export AR='$(AR)'" >> $@
$(VERBOSE)echo "export LD='$(LD)'" >> $@
$(VERBOSE)echo "export CPPFLAGS='$(NOUX_CPPFLAGS)'" >> $@
Expand Down
31 changes: 28 additions & 3 deletions ports/ports/gcc.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GCC_VERSION = 4.4.5
GCC_VERSION = 4.6.1
GCC = gcc-$(GCC_VERSION)
GCC_URL = ftp://ftp.fu-berlin.de/gnu/gcc

Expand All @@ -10,7 +10,7 @@ GCC_CXX_TGZ = gcc-g++-$(GCC_VERSION).tar.gz
#
PORTS += $(GCC)

prepare:: $(CONTRIB_DIR)/$(GCC)
prepare:: $(CONTRIB_DIR)/$(GCC)/configure

#
# Port-specific local rules
Expand All @@ -22,7 +22,32 @@ $(DOWNLOAD_DIR)/$(GCC_CORE_TGZ):
$(DOWNLOAD_DIR)/$(GCC_CXX_TGZ):
$(VERBOSE)wget -P $(DOWNLOAD_DIR) $(GCC_URL)/$(GCC)/$(GCC_CXX_TGZ) && touch $@

#
# Utilities
#
AUTOCONF = autoconf2.64

#
# Check if 'autoconf' is installed
#
ifeq ($(shell which $(AUTOCONF)),)
$(error Need to have '$(AUTOCONF)' installed.)
endif

#
# Check if 'autogen' is installed
#
ifeq ($(shell which autogen)),)
$(error Need to have 'autogen' installed.)
endif

$(CONTRIB_DIR)/$(GCC): $(DOWNLOAD_DIR)/$(GCC_CORE_TGZ) $(DOWNLOAD_DIR)/$(GCC_CXX_TGZ)
$(VERBOSE)for i in $^ ; do tar xfz $$i -C $(CONTRIB_DIR) ;done
$(VERBOSE)patch -N -p0 < src/noux-pkg/gcc/build.patch

include ../tool/tool_chain_gcc_patches.inc

$(CONTRIB_DIR)/$(GCC)/configure:: $(CONTRIB_DIR)/$(GCC)
@#
@# Noux-specific changes
@#
$(VERBOSE)patch -d $(CONTRIB_DIR)/$(GCC) -N -p1 < src/noux-pkg/gcc/build.patch
61 changes: 51 additions & 10 deletions ports/run/noux_tool_chain.run
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
if {![have_spec x86_32]} {
puts "\nThe Noux tool chain scenario is supported on the x86_32 architecture only\n"
exit 0
}
#
# Uncomment the following line when working on the binutils source code. Otherwise,
# the package may get recompiled, yet it does not get reinstalled into 'bin/'.
#
#exec rm -rf noux-pkg/binutils bin/binutils

#
# Uncomment the following line when working on the GCC source code. Otherwise,
# the package may get recompiled, yet it does not get reinstalled into 'bin/'.
#
#exec rm -rf noux-pkg/gcc bin/gcc

#
# Uncomment the following line when working on the make source code. Otherwise,
# the package may get recompiled, yet it does not get reinstalled into 'bin/'.
#
#exec rm -rf noux-pkg/make bin/make

set build_components {
core init drivers/timer noux/minimal lib/libc_noux
Expand All @@ -10,10 +23,27 @@ set build_components {
test/libports/ncurses
}

set cc_march ""

if {[have_spec arm]} {
set binutils "binutils_arm"
set gcc "gcc_arm"
set tool_prefix "genode-arm-"
}

if {[have_spec x86]} {
set binutils "binutils_x86"
set gcc "gcc_x86"
set tool_prefix "genode-x86-"
if {[have_spec x86_32]} {
set cc_march "-m32"
}
}

#
# Build Noux packages only once
#
set noux_pkgs {bash coreutils vim findutils binutils gcc make}
set noux_pkgs "bash coreutils vim findutils make $binutils $gcc"

foreach pkg $noux_pkgs {
lappend_if [expr ![file exists bin/$pkg]] build_components noux-pkg/$pkg }
Expand Down Expand Up @@ -114,15 +144,22 @@ append config {
<content>
<dir name="tmp">
<inline name="a.c">int main(int argc, char **argv) { return 0; }</inline>
<inline name="Makefile">
<inline name="Makefile"> }
append config "
SHELL=/bin/bash
all:
genode-x86-gcc -v -c a.c -o a.o
${tool_prefix}gcc $cc_march -v -c a.c -o a.o
"
append config {
</inline>
</dir>
<dir name="home">
<dir name="user">
<inline name=".bash_profile">cd /tmp; make; genode-x86-readelf -a a.o</inline>
<inline name=".bash_profile">
cd /tmp; make; }
append config "${tool_prefix}readelf -a a.o"
append config {
</inline>
</dir>
</dir>
</content>
Expand Down Expand Up @@ -177,7 +214,7 @@ set boot_modules {
core init timer ld.lib.so noux terminal ram_fs
libc.lib.so libm.lib.so libc_noux.lib.so ncurses.lib.so }

append boot_modules { gmp.lib.so mpfr.lib.so }
append boot_modules { gmp.lib.so mpfr.lib.so mpc.lib.so }

foreach pkg $noux_pkgs {
lappend boot_modules "$pkg.tar" }
Expand All @@ -191,7 +228,11 @@ lappend_if [have_spec pl11x] boot_modules pl11x_drv

build_boot_image $boot_modules

append qemu_args " -m 300 "
if {[have_spec x86_64]} {
append qemu_args " -m 500 "
} else {
append qemu_args " -m 320 "
}

run_genode_until forever

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
PROGRAM_PREFIX = genode-x86-

NOUX_CFLAGS += -std=c99
NOUX_CONFIGURE_ARGS = --disable-werror \
--program-prefix=$(PROGRAM_PREFIX) \
--target=i686-freebsd
--target=$(BINUTILS_TARGET)

#
# Pass CFLAGS and friends to the invokation of 'make' because
Expand All @@ -12,4 +10,6 @@ NOUX_CONFIGURE_ARGS = --disable-werror \
#
NOUX_MAKE_ENV = $(NOUX_ENV)

NOUX_PKG_DIR = $(wildcard $(REP_DIR)/contrib/binutils-*)

include $(REP_DIR)/mk/noux.mk
4 changes: 4 additions & 0 deletions ports/src/noux-pkg/binutils_arm/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PROGRAM_PREFIX = genode-arm-
BINUTILS_TARGET = arm-elf-eabi

include $(PRG_DIR)/../binutils/target.inc
4 changes: 4 additions & 0 deletions ports/src/noux-pkg/binutils_x86/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PROGRAM_PREFIX = genode-x86-
BINUTILS_TARGET = x86_64-elf

include $(PRG_DIR)/../binutils/target.inc
Loading

0 comments on commit e39200d

Please sign in to comment.