Opened 12 years ago

Closed 12 years ago

#8415 closed bug (fixed)

[patch] Fix x86_64 toolchain

Reported by: xyzzy Owned by: bonefish
Priority: normal Milestone: R1
Component: Build System Version: R1/Development
Keywords: gsoc2012 Cc:
Blocked By: Blocking:
Platform: x86-64

Description

The x86_64 toolchain currently fails to build.

The first build failure appears to be a problem with GCC's build system: it defaults to having multilib enabled, but if it is explicitly enabled with --enable-multilib as Haiku's build script does, the build fails. The patch to Haiku trunk removes --enable-multilib for the x86_64 target, I'm not sure if this issue affects the other targets that specify --enable-multilib.

A second build failure occurs due to the use of the TARGET_64BIT definition in preprocessor conditionals in the haiku64.h configuration file for GCC, as it is no longer a compile-time constant. The patch to buildtools fixes this, and also includes some other changes I made to the x86_64 target definition to be more correct.

Attachments (2)

haiku-x86_64-cross-tools.patch (1.1 KB ) - added by xyzzy 12 years ago.
Patch to build cross tools script for x86_64
buildtools-x86_64.patch (7.9 KB ) - added by xyzzy 12 years ago.
Patch to build tools for x86_64

Download all attachments as: .zip

Change History (12)

comment:1 by xyzzy, 12 years ago

patch: 01

comment:2 by xyzzy, 12 years ago

Component: - GeneralBuild System
Owner: changed from nobody to bonefish
Platform: Allx86-64

comment:3 by bonefish, 12 years ago

Keywords: gsoc2012 added
Version: R1/alpha3R1/Development

Alex, thanks for the patch. Although a few Haiku developers have meddled with gcc, I believe none of us is anything close to an expert. So reviewing the patch is not really trivial. Would you mind walking us through the changes? Just a short sentence for each, explaining what changed why.

Please note: I'm rather busy with real life ATM, so, unless someone else takes action, don't hold your breath for anything to happen very soon.

comment:4 by xyzzy, 12 years ago

I don't claim to be an expert in GCC either ;) Basically what I did was changed it so that it matches the existing i386 Haiku target when generating 32-bit code, and changed some things to match x86-64.h for 64-bit code.

I'll go through each change in the buildtools patch:

  • First one just changes TARGET_64BIT to TARGET_64BIT_DEFAULT, as I said TARGET_64BIT is not a compile-time constant.
  • Second one just changes the comment to say that DEFAULT_PCC_STRUCT_RETURN is necessary: it is currently set on the Haiku i386 target, the ABI specifies that structs and unions must be returned in memory. When compiling 64-bit code, GCC just ignores this definition.
  • Third one just changes the builtin definitions to not treat TARGET_64BIT as a constant. Also removes the definition of __x86_64__, this is set in GCC's i386-c.c.
  • Fourth one changes LINK_SPEC not to be set using TARGET_64BIT. I've also removed -z max-page-size as I don't believe it should be necessary: the default page size is 2MB but this won't result in large binaries, it just changes the alignment of the sections and would make it easier to map binaries using large pages in the future.
  • The next changes change it to match x86-64.h to handle some x86_64 ABI stuff.
  • Finally, the last change just removes TARGET_64BIT around the debugging definitions. These are all set for the i386 target anyway so there's no need for a conditional round them.

comment:5 by bonefish, 12 years ago

Thanks for the explanations. Please redo the patches with git format-patch so you'll get credited correctly. Your previous explanations are a good base for the commit message. :-)

by xyzzy, 12 years ago

Patch to build cross tools script for x86_64

comment:6 by bonefish, 12 years ago

The buildtools patch doesn't apply. Please rebase it.

by xyzzy, 12 years ago

Attachment: buildtools-x86_64.patch added

Patch to build tools for x86_64

comment:7 by xyzzy, 12 years ago

Sorry, didn't think there would have been any changes to the x86_64 target files so didn't pull before creating the patch. Uploaded a new one.

comment:8 by korli, 12 years ago

About haiku-x86_64-cross-tools.patch, I know gcc build has a problem with building zlib as part of a cross compiler for arm because of multilib. A workaround is to use the system zlib, which I think is acceptable, even on Haiku.

comment:9 by xyzzy, 12 years ago

That's the same issue as I was getting for x86_64. I don't know whether multilib is on by default for ARM if you don't enable it explicitly (it is for x86_64). If you'd prefer to change it to use the system zlib instead then I think that would work for x86_64.

comment:10 by bonefish, 12 years ago

Resolution: fixed
Status: newclosed

Thanks, applied both patches as btrev43030 and hrev43954 respectively.

No clue about the ARM build. I don't even know what multilib would target in this case.

Note: See TracTickets for help on using tickets.