Opened 4 years ago

Last modified 15 months ago

#3814 new feature request

Compile to more than one (sub)-architecture

Reported by: filcab Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.12.1
Keywords: architecture, compiler, x86_64 Cc: filcab+ghc@…, karel.gardas@…, dankna@…, william.knop.nospam@…, shelarcy@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo)

GHC, as far as I can tell, can only compile files for one architecture (let's call it the "host architecture").

This brings some problems... The biggest of which is that we lose the option of building for 32/64 bits in one of the "hybrid" architectures (For example, in x86_64-linux or i386-darwin)

If I build a ghc in a x86_64 linux I will only get the x86_64 code generator and not the i386 generator. This will stop me from building a program which links with a library that only has a 32-bit version.
If I want a GHC which will only compile for the i386, I will have to cross-compile, which is not very pretty.

The same will happen on the Mac OS X side (even though the x86_64-darwin port is still on its way...).

But GHC "should" (IMHO) be able to do like GCC and be able to generate code for both architecturess (i386 and x86_64), through the usage of compiler flags (which would also be passed to any gcc sub-process, if need be). At least if it is installed in a x86_64 (and PPC, if PPC64 is supported) system.

Even better would be to do like LLVM's llc which enables a user to generate an assembly file for a target architecture from any other architecture.

Example of an LLVM target list:

filcab@fry:/stuff/src> llc --version
Low Level Virtual Machine (http://llvm.org/):
  llvm version 2.7svn
  DEBUG build with assertions.
  Built Jan 10 2010 (00:25:59).
  Host: x86_64-unknown-linux-gnu
  Host CPU: core2

  Registered Targets:
    arm     - ARM
    c       - C backend
    cellspu - STI CBEA Cell SPU [experimental]
    cpp     - C++ backend
    mips    - Mips
    msil    - MSIL backend
    ppc64   - PowerPC 64
    sparc   - Sparc
    x86     - 32-bit X86: Pentium-Pro and above
    x86-64  - 64-bit X86: EM64T and AMD64

Change History (8)

comment:1 Changed 4 years ago by filcab

  • Cc filcab+ghc@… added

comment:2 Changed 4 years ago by igloo

  • Description modified (diff)

comment:3 Changed 4 years ago by igloo

  • Milestone set to _|_

This is something we're slowly working towards. See also #964.

comment:4 Changed 3 years ago by kgardas

  • Cc karel.gardas@… added

comment:5 Changed 3 years ago by dankna

  • Cc dankna@… added

comment:6 Changed 3 years ago by altaic

  • Cc william.knop.nospam@… added

comment:7 Changed 15 months ago by morabbin

See also #964.

comment:8 Changed 15 months ago by shelarcy

  • Cc shelarcy@… added
Note: See TracTickets for help on using tickets.