[haiku-commits] BRANCH xyzzy-github.x86_64 - src/system/libroot/posix/malloc_debug build/scripts

  • From: xyzzy-github.x86_64 <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 16 Aug 2012 18:49:14 +0200 (CEST)

added 2 changesets to branch 'refs/remotes/xyzzy-github/x86_64'
old head: c864ba1a2d8525aeabd6199c01675f70f5abd7bd
new head: aaeadfcb02fea79141251cd3a9f872d6f47fc244

----------------------------------------------------------------------------

1eaa9e6: Compilation fix for malloc_debug.

aaeadfc: Do a separate libgcc build for the kernel as well.
  
  Turns out that libgcc is needed, for some reason building the kernel
  with -O0 does not end up referencing libgcc but -O2 does. A separate
  build of it is done with -mno-red-zone, same reason as for libsupc++.
  Ended up being easy to rebuild with different CFLAGS: previously I'd
  tried doing `CFLAGS="-mno-red-zone" make` in the libgcc dir which
  didn't override, the correct way is `make CFLAGS="-mno-red-zone"`

                                      [ Alex Smith <alex@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 54 insertions(+), 37 deletions(-)
build/scripts/build_cross_tools_gcc4           |   30 ++++++++++------
configure                                      |   23 +++++++-----
src/system/libroot/posix/malloc_debug/heap.cpp |   38 +++++++++++---------

############################################################################

Commit:      1eaa9e63cd2d8ce8ed11974e0314860bdd4eb621

Author:      Alex Smith <alex@xxxxxxxxxxxxxxxx>
Date:        Thu Aug 16 13:23:43 2012 UTC

Compilation fix for malloc_debug.

----------------------------------------------------------------------------

diff --git a/src/system/libroot/posix/malloc_debug/heap.cpp 
b/src/system/libroot/posix/malloc_debug/heap.cpp
index 0753f67..074cada 100644
--- a/src/system/libroot/posix/malloc_debug/heap.cpp
+++ b/src/system/libroot/posix/malloc_debug/heap.cpp
@@ -204,15 +204,16 @@ dump_page(heap_page *page)
                count++;
 
        printf("\t\tpage %p: bin_index: %u; free_count: %u; empty_index: %u; "
-               "free_list %p (%lu entr%s)\n", page, page->bin_index, 
page->free_count,
-               page->empty_index, page->free_list, count, count == 1 ? "y" : 
"ies");
+               "free_list %p (%" B_PRIu32 " entr%s)\n", page, page->bin_index,
+               page->free_count, page->empty_index, page->free_list, count,
+               count == 1 ? "y" : "ies");
 }
 
 
 static void
 dump_bin(heap_bin *bin)
 {
-       printf("\telement_size: %lu; max_free_count: %u; page_list %p;\n",
+       printf("\telement_size: %" B_PRIu32 "; max_free_count: %u; page_list 
%p;\n",
                bin->element_size, bin->max_free_count, bin->page_list);
 
        for (heap_page *temp = bin->page_list; temp != NULL; temp = temp->next)
@@ -234,10 +235,11 @@ dump_allocator_areas(heap_allocator *heap)
 {
        heap_area *area = heap->all_areas;
        while (area) {
-               printf("\tarea %p: area: %ld; base: 0x%08lx; size: %lu; 
page_count: "
-                       "%lu; free_pages: %p (%lu entr%s)\n", area, area->area, 
area->base,
-                       area->size, area->page_count, area->free_pages,
-                       area->free_page_count, area->free_page_count == 1 ? "y" 
: "ies");
+               printf("\tarea %p: area: %" B_PRId32 "; base: 0x%08lx; size: 
%lu; "
+                       "page_count: %" B_PRIu32 "; free_pages: %p (%" B_PRIu32 
" entr%s)\n",
+                       area, area->area, area->base, area->size, 
area->page_count,
+                       area->free_pages, area->free_page_count,
+                       area->free_page_count == 1 ? "y" : "ies");
                area = area->all_next;
        }
 
@@ -248,10 +250,11 @@ dump_allocator_areas(heap_allocator *heap)
 static void
 dump_allocator(heap_allocator *heap, bool areas, bool bins)
 {
-       printf("allocator %p: name: %s; page_size: %lu; bin_count: %lu; pages: "
-               "%lu; free_pages: %lu; empty_areas: %lu\n", heap, heap->name,
-               heap->page_size, heap->bin_count, heap->total_pages,
-               heap->total_free_pages, heap->empty_areas);
+       printf("allocator %p: name: %s; page_size: %" B_PRIu32 "; bin_count: %"
+               B_PRIu32 "; pages: %" B_PRIu32 "; free_pages: %" B_PRIu32 "; "
+               "empty_areas: %" B_PRIu32 "\n", heap, heap->name, 
heap->page_size,
+               heap->bin_count, heap->total_pages, heap->total_free_pages,
+               heap->empty_areas);
 
        if (areas)
                dump_allocator_areas(heap);
@@ -304,8 +307,8 @@ dump_allocations(bool statsOnly, thread_id thread)
                                                if (thread == -1 || 
info->thread == thread) {
                                                        // interesting...
                                                        if (!statsOnly) {
-                                                               printf("thread: 
% 6ld; address: 0x%08lx;"
-                                                                       " size: 
%lu bytes\n", info->thread,
+                                                               printf("thread: 
% 6" B_PRId32 "; address: "
+                                                                       
"0x%08lx; size: %lu bytes\n", info->thread,
                                                                        base, 
info->size);
                                                        }
 
@@ -330,7 +333,7 @@ dump_allocations(bool statsOnly, thread_id thread)
                                        if (thread == -1 || info->thread == 
thread) {
                                                // interesting...
                                                if (!statsOnly) {
-                                                       printf("thread: % 6ld; 
address: 0x%08lx;"
+                                                       printf("thread: % 6" 
B_PRId32 "; address: 0x%08lx;"
                                                                " size: %lu 
bytes\n", info->thread,
                                                                base, 
info->size);
                                                }
@@ -348,7 +351,8 @@ dump_allocations(bool statsOnly, thread_id thread)
                }
        }
 
-       printf("total allocations: %lu; total bytes: %lu\n", totalCount, 
totalSize);
+       printf("total allocations: %" B_PRIu32 "; total bytes: %lu\n", 
totalCount,
+               totalSize);
 }
 
 
@@ -1618,7 +1622,7 @@ heap_create_new_heap_area(heap_allocator *heap, const 
char *name, size_t size)
 static int32
 heap_wall_checker(void *data)
 {
-       int msInterval = (int32)data;
+       int msInterval = (addr_t)data;
        while (!sStopWallChecking) {
                heap_validate_walls();
                snooze(msInterval * 1000);
@@ -1636,7 +1640,7 @@ heap_debug_start_wall_checking(int msInterval)
 {
        if (sWallCheckThread < 0) {
                sWallCheckThread = spawn_thread(heap_wall_checker, "heap wall 
checker",
-                       B_LOW_PRIORITY, (void *)msInterval);
+                       B_LOW_PRIORITY, (void *)(addr_t)msInterval);
        }
 
        if (sWallCheckThread < 0)

############################################################################

Commit:      aaeadfcb02fea79141251cd3a9f872d6f47fc244

Author:      Alex Smith <alex@xxxxxxxxxxxxxxxx>
Date:        Thu Aug 16 16:38:01 2012 UTC

Do a separate libgcc build for the kernel as well.

Turns out that libgcc is needed, for some reason building the kernel
with -O0 does not end up referencing libgcc but -O2 does. A separate
build of it is done with -mno-red-zone, same reason as for libsupc++.
Ended up being easy to rebuild with different CFLAGS: previously I'd
tried doing `CFLAGS="-mno-red-zone" make` in the libgcc dir which
didn't override, the correct way is `make CFLAGS="-mno-red-zone"`

----------------------------------------------------------------------------

diff --git a/build/scripts/build_cross_tools_gcc4 
b/build/scripts/build_cross_tools_gcc4
index 9397c7a..3298bf4 100755
--- a/build/scripts/build_cross_tools_gcc4
+++ b/build/scripts/build_cross_tools_gcc4
@@ -33,7 +33,7 @@ x86_64-*)
        # failure
        binutilsConfigureArgs=""
        gccConfigureArgs=""
-       kernelSupcxxFlags="-mno-red-zone"
+       kernelCcFlags="-mno-red-zone"
        ;;
 m68k-*)
        binutilsConfigureArgs="--enable-multilib"
@@ -46,7 +46,7 @@ arm-*)
 *)
        binutilsConfigureArgs="--disable-multilib"
        gccConfigureArgs="--disable-multilib"
-       kernelSupcxxFlags=
+       kernelCcFlags=
        ;;
 esac
 
@@ -166,18 +166,26 @@ $MAKE $additionalMakeArgs install || {
        exit 1
 }
 
-# build libsupc++ for the kernel if the target arch requires it
-if [ -n "$kernelSupcxxFlags" ]; then
-       cd $stdcxxObjDir
-       CFLAGS="-O2 $kernelSupcxxFlags" CXXFLAGS="-O2 $kernelSupcxxFlags" \
-               $gccSourceDir/libstdc++-v3/configure --prefix=$installDir \
-               --target=$haikuMachine --host=$haikuMachine --disable-shared \
-               --disable-multilib || exit 1
-       $MAKE $additionalMakeArgs -C libsupc++ || {
+# build libraries for the kernel if the target arch requires it
+if [ -n "$kernelCcFlags" ]; then
+       $MAKE -C $haikuMachine/libgcc clean
+       $MAKE -C $haikuMachine/libgcc CFLAGS="-g -O2 $kernelCcFlags" || {
+               echo "Error: Building kernel libgcc failed." >&2
+               exit 1
+       }
+
+       cp $haikuMachine/libgcc/libgcc.a \
+               $installDir/$haikuMachine/lib/libgcc-kernel.a || exit 1
+
+       $MAKE -C $haikuMachine/libstdc++-v3/libsupc++ clean
+       $MAKE -C $haikuMachine/libstdc++-v3/libsupc++ CFLAGS="-g -O2 
$kernelCcFlags" \
+               CXXFLAGS="-g -O2 $kernelCcFlags" || {
                echo "Error: Building kernel libsupc++ failed." >&2
                exit 1
        }
-       cp libsupc++/.libs/libsupc++.a 
$installDir/$haikuMachine/lib/libsupc++-kernel.a
+
+       cp $haikuMachine/libstdc++-v3/libsupc++/.libs/libsupc++.a \
+               $installDir/$haikuMachine/lib/libsupc++-kernel.a || exit 1
 fi
 
 # cleanup
diff --git a/configure b/configure
index 571f3a0..f43bac6 100755
--- a/configure
+++ b/configure
@@ -188,6 +188,17 @@ standard_gcc_settings()
                        HAIKU_STATIC_LIBSUPCXX=`$HAIKU_CC 
-print-file-name=libsupc++.a`
                        HAIKU_SHARED_LIBSUPCXX=`$HAIKU_CC 
-print-file-name=libsupc++.so`
 
+                       # If the architecture has separate runtime libraries 
for the
+                       # kernel, use them.
+                       HAIKU_KERNEL_LIBGCC=`$HAIKU_CC 
-print-file-name=libgcc-kernel.a`
+                       if [ $HAIKU_KERNEL_LIBGCC = libgcc-kernel.a ]; then
+                               HAIKU_KERNEL_LIBGCC=$HAIKU_GCC_LIBGCC
+                       fi
+                       HAIKU_KERNEL_LIBSUPCXX=`$HAIKU_CC 
-print-file-name=libsupc++-kernel.a`
+                       if [ $HAIKU_KERNEL_LIBSUPCXX = libsupc++-kernel.a ]; 
then
+                               HAIKU_KERNEL_LIBSUPCXX=$HAIKU_STATIC_LIBSUPCXX
+                       fi
+
                        local headers
                        if [ -d 
$gccdir/../../../../$HAIKU_GCC_MACHINE/include/c++/$HAIKU_GCC_RAW_VERSION ]; 
then
                                
headers=$gccdir/../../../../$HAIKU_GCC_MACHINE/include/c++/$HAIKU_GCC_RAW_VERSION
@@ -240,23 +251,17 @@ standard_gcc_settings()
                                echo "Please download it from 
www.haiku-os.org...";
                                exit 1;
                        fi
+
+                       HAIKU_KERNEL_LIBGCC=$HAIKU_GCC_LIBGCC
+                       HAIKU_KERNEL_LIBSUPCXX=
                ;;
        esac
 
        if [ "$targetArch" = "x86_64" ]; then
-               # Kernel doesn't need libgcc, and has a special version of 
libsupc++
-               # built with the correct flags. Note: Should libgcc ever be 
needed for
-               # the x86_64 kernel, a separate build of it will be needed with
-               # -mno-red-zone, like for libsupc++.
-               HAIKU_KERNEL_LIBGCC=
-               HAIKU_KERNEL_LIBSUPCXX=`$HAIKU_CC 
-print-file-name=libsupc++-kernel.a`
-
                # Boot loader is 32-bit, need the 32-bit libs.
                HAIKU_BOOT_LIBGCC=`$HAIKU_CC -m32 -print-libgcc-file-name`
                HAIKU_BOOT_LIBSUPCXX=`$HAIKU_CC -m32 
-print-file-name=libsupc++.a`
        else
-               HAIKU_KERNEL_LIBGCC=$HAIKU_GCC_LIBGCC
-               HAIKU_KERNEL_LIBSUPCXX=$HAIKU_STATIC_LIBSUPCXX
                HAIKU_BOOT_LIBGCC=$HAIKU_GCC_LIBGCC
                HAIKU_BOOT_LIBSUPCXX=$HAIKU_STATIC_LIBSUPCXX
        fi


Other related posts:

  • » [haiku-commits] BRANCH xyzzy-github.x86_64 - src/system/libroot/posix/malloc_debug build/scripts - xyzzy-github . x86_64