Reduce the likelihood of x64/x86-64 changes breaking the build on other arches
The file compiler/nativeGen/X86/Regs.hs is causing rather a lot of trouble for people on CPUs other than x86 and x86-86. Problems like these two:
The problem is caused by code like this:
# if i386_TARGET_ARCH
someFuncion = .....
# elif x86_64_TARGET_ARCH
someFuncion = .....
# else
someFuncion = .....
# endif
Code like this becomes problematic (ie fails to compile on non x86/x86-64) under a number of related obscure conditions like:
- someFunction is exported from the module, but the #else part is forgotten, causing the compile to fail.
- someFunction has a function signature but the #else part is forgotten resulting in a signature with no implmentation.
- someFunction uses an import module on x86 or x86-64 that isn't used in the #else cases causing a compile error with -Werror (eg validate).
Fortunately, I think there is a simple solution to this. If we chose one of these arches to be the default (say x86-64) then all instances of the above pattern could be rewritten as:
# if i386_TARGET_ARCH
someFuncion = .....
# else
someFuncion = .....
# endif
meaning that on PowerPC and ARM, the x86 code generator only generates code for x86-64 (the default), but makes the code simpler in general and easier to get right.
I am currently working on a patch which provides this functionality.
Trac metadata
Trac field | Value |
---|---|
Version | 7.5 |
Type | Task |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |