Unable to compile buildtools in macOS

I’m trying to build haiku in macOS but when I try to compile buildtools for x86 architecture it fails. Below I’ve attached last part of what is shown on my terminal. Can anyone help?

config.status: executing default commands

if [ x"-fPIC" != x ] && [ ! -d pic ]; then \

mkdir pic; \

else true; fi

touch stamp-picdir

if [ x"-fPIC" != x ]; then \

gcc -c -DHAVE_CONFIG_H -O2 -fcommon -I. -I/Volumes/Haiku/buildtools/legacy/binutils/libiberty/../include -W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes -Wc++-compat -fPIC /Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c -o pic/regex.o; \

else true; fi

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:130:14:** **warning:** **this function declaration is not a prototype [-Wstrict-prototypes]**

char *malloc ();

**^**

void

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:130:7:** **warning:** **incompatible redeclaration of library function 'malloc' [-Wincompatible-library-redeclaration]**

char *malloc ();

**^**

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:130:7: note:** 'malloc' is a builtin with type 'void *(unsigned long)'

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:131:15:** **warning:** **this function declaration is not a prototype [-Wstrict-prototypes]**

char *realloc ();

**^**

void

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:131:7:** **warning:** **incompatible redeclaration of library function 'realloc' [-Wincompatible-library-redeclaration]**

char *realloc ();

**^**

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:131:7: note:** 'realloc' is a builtin with type 'void *(void *, unsigned long)'

In file included from /Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:638:

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:2439:33:** **error:** **implicitly declaring library function 'free' with type 'void (void *)' [-Werror,-Wimplicit-function-declaration]**

if (!COMPILED_BUFFER_VAR) FREE_STACK_RETURN (REG_ESPACE);

**^**

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:2278:11: note:** expanded from macro 'FREE_STACK_RETURN'

return (free (compile_stack.stack), value)

**^**

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:2439:33: note:** include the header <stdlib.h> or explicitly provide a declaration for 'free'

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:2278:11: note:** expanded from macro 'FREE_STACK_RETURN'

return (free (compile_stack.stack), value)

**^**

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:4835:11:** **error:** **implicitly declaring library function 'abort' with type 'void (void) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]**

abort (); /* We have listed all the cases. */

**^**

**/Volumes/Haiku/buildtools/legacy/binutils/libiberty/regex.c:4835:11: note:** include the header <stdlib.h> or explicitly provide a declaration for 'abort'

4 warnings and 2 errors generated.

make[2]: *** [regex.o] Error 1

make[1]: *** [all-libiberty] Error 2

make: *** [all] Error 2

What are your build steps?

I’m following the user guide at: Building Haiku | Haiku Project
I tried executing:

./configure --cross-tools-source ../buildtools --build-cross-tools x86_gcc2 --build-cross-tools x86

I also tried building for x86_64 but that too threw me similar warnings and errors from compiler.

Similar or exactly the same?

That path looks strange. It’s usually ../../buildtools and ../configure. Did you create a generated directory and cd into it?

Edit: I guess configuring from the top-level is supported, I just never do it that way. The x86_64 page shows working in a clean directory.

Similar in the sense that there were warnings regarding various files. Building for x86_64 throws a much longer error. I’m attaching a small part of the log if it is of any use: build error - Pastebin.com

I’ve tried working in a clean directory too. It’s still the same.

On the 64bit version the problem is caused by an error in the merge of gcc 11.2. We had a patch to this file that was incorrectly applied, and two #include statements were removed.

I have discussed this with anuragpd4 on IRC and will let them test the change and submit the patch if it works.

4 Likes

For arch x86_64 everything runs fine.

For arch x86_gcc2 we still have above mentioned errors, I modified files :

buildtools/legacy/binutils/libiberty/regex.c
buildtools/legacy/binutils/libiberty/md5.c

by removing macro around #include<stdlib.h>.

Though that fixed all the above errors we still got one when building cross tools

 clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** The command 'gcc -m32 -o conftest -O2 -U_FORTIFY_SOURCE -fcommon   conftest.c' failed.
*** You must set the environment variable CC to a working compiler.

There was this similar error on FreeBSD reported here https://www.freelists.org/post/haiku-development/usrlocalbinld-cannot-find-ldl-what-is-this

So I think we need to modify build/jam/buildsetup for MacOS as well.

Anyone familiar could help me here?

1 Like

Do you really need to build for gcc2? That will indeed be troublesome on modern architectures and on non-Linux machines generally. I think the best way is to work on x86_64 only, and rely on the buildbot in Gerrit to check your changes with gcc2 and 32bit systems. Unless you are really interested in spending time fixing compiler problems.

Actually I got build error for gcc2 on gerrit, I thought maybe it will be good idea to have buildtools for that as well, so I can check my changes on gcc2.
It isn’t much necessity since x86_64 works fine.

1 Like