compiler selection on PPC
Ken Cunningham
ken.cunningham.webuse at gmail.com
Sun Dec 31 19:32:49 UTC 2017
On 2017-12-06, at 12:19 PM, Ken Cunningham wrote:
> There have been a number of tickets over the past two years that relate to compiler selection on PPC systems.
>
> Basically, on PPC, if the default compiler (gcc 4.2 on 10.5, or apple-gcc42 on Tiger) does not work to build a port, the only other compiler that should be then used is gcc6. Maybe someday this might be gcc7, if we fix up the extra errors found in gcc7.
>
> Presently, however, PPC systems go down the same compiler selection path as Intel systems. That usually leads to clang 3.3 or clang 3.4 being selected, and this always fails miserably on PPC.
>
> Finally, there are a number of ports that blacklist all gcc compilers like this *gcc* . This is often appropriate for Intel systems, but completely wrong for PPC. So I don't know if it is possible to clear or ignore that setting in a Portfile -- probably not, but when I set the default_compiler in macports.conf, it does appear override that setting, so maybe it is possible.
>
> Thanks,
>
> Ken
Here’s my first attempt at fixing compiler selection on PPC.
Basically, I’d like MacPorts to run through the standard Xcode compilers, but if they are all blacklisted, to fall back to gcc6 rather than clang*.
This seems to do this correctly at present.
Feedback appreciated as this is deep in the guts of macports.
DIFF
===========
--- /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl.orig 2017-12-31 11:00:11.000000000 -0800
+++ /opt/local/libexec/macports/lib/port1.0/portconfigure.tcl 2017-12-31 11:16:37.000000000 -0800
@@ -473,7 +473,7 @@
# internal function to choose compiler fallback list based on platform
proc portconfigure::get_compiler_fallback {} {
- global xcodeversion macosx_deployment_target default_compilers configure.sdkroot configure.cxx_stdlib os.major
+ global xcodeversion macosx_deployment_target default_compilers configure.sdkroot configure.cxx_stdlib os.major configure.build_arch
# Check our override
if {[info exists default_compilers]} {
@@ -492,9 +492,17 @@
return {gcc-4.0}
}
} elseif {[vercmp $xcodeversion 3.0] >= 0} {
- return {gcc-4.2 apple-gcc-4.2 gcc-4.0 macports-clang-3.4 macports-clang-3.3}
+ if {${configure.build_arch} eq "ppc" || ${configure.build_arch} eq "ppc64"} {
+ return {macports-gcc-6 gcc-4.2 apple-gcc-4.2 gcc-4.0 macports-gcc-7}
+ } else {
+ return {gcc-4.2 apple-gcc-4.2 gcc-4.0 macports-clang-3.4 macports-clang-3.3}
+ }
} else {
- return {apple-gcc-4.2 gcc-4.0 gcc-3.3 macports-clang-3.3}
+ if {${configure.build_arch} eq "ppc" || ${configure.build_arch} eq "ppc64"} {
+ return {macports-gcc-6 apple-gcc-4.2 gcc-4.0 macports-gcc-6 macports-gcc-7}
+ } else {
+ return {apple-gcc-4.2 gcc-4.0 gcc-3.3 macports-clang-3.3}
+ }
}
}
@@ -531,10 +539,16 @@
# We dropped support for these compilers on Sierra
lappend compilers macports-clang-3.4 macports-llvm-gcc-4.2 apple-gcc-4.2
}
+
+ # on PPC, only these compilers are useful at present
+ if {${configure.build_arch} eq "ppc" || ${configure.build_arch} eq "ppc64"} {
+ set compilers {gcc-4.2 apple-gcc-4.2 macports-gcc-6 macports-gcc-7}
+ }
return $compilers
}
+
# Find a developer tool
proc portconfigure::find_developer_tool {name} {
global developer_dir
=========================
MODIFIED FUNCTION
==============
# internal function to choose compiler fallback list based on platform
proc portconfigure::get_compiler_fallback {} {
global xcodeversion macosx_deployment_target default_compilers configure.sdkroot configure.cxx_stdlib os.major configure.build_arch
# Check our override
if {[info exists default_compilers]} {
return $default_compilers
}
# Check for platforms without Xcode
if {$xcodeversion eq "none" || $xcodeversion eq ""} {
return {cc}
}
# Legacy cases
if {[vercmp $xcodeversion 4.0] < 0} {
if {[vercmp $xcodeversion 3.2] >= 0} {
if {[string match *10.4u* ${configure.sdkroot}]} {
return {gcc-4.0}
}
} elseif {[vercmp $xcodeversion 3.0] >= 0} {
if {${configure.build_arch} eq "ppc" || ${configure.build_arch} eq "ppc64"} {
return {macports-gcc-6 gcc-4.2 apple-gcc-4.2 gcc-4.0 macports-gcc-7}
} else {
return {gcc-4.2 apple-gcc-4.2 gcc-4.0 macports-clang-3.4 macports-clang-3.3}
}
} else {
if {${configure.build_arch} eq "ppc" || ${configure.build_arch} eq "ppc64"} {
return {macports-gcc-6 apple-gcc-4.2 gcc-4.0 macports-gcc-6 macports-gcc-7}
} else {
return {apple-gcc-4.2 gcc-4.0 gcc-3.3 macports-clang-3.3}
}
}
}
set compilers {}
# Set our preferred Xcode-provided compilers
if {[vercmp $xcodeversion 5.0] >= 0} {
lappend compilers clang
} elseif {[vercmp $xcodeversion 4.3] >= 0} {
lappend compilers clang llvm-gcc-4.2
} elseif {[vercmp $xcodeversion 4.0] >= 0} {
lappend compilers llvm-gcc-4.2 clang
} else {
lappend compilers gcc-4.2 clang llvm-gcc-4.2
}
# Determine which versions of clang we prefer
if {${configure.cxx_stdlib} eq "libc++"} {
# clang-3.5+ require libc++
lappend compilers macports-clang-4.0
if {${os.major} < 17} {
# The High Sierra SDK requires a toolchain that can apply nullability to uuid_t
lappend compilers macports-clang-3.9
}
if {${os.major} < 16} {
# The Sierra SDK requires a toolchain that supports class properties
lappend compilers macports-clang-3.8 macports-clang-3.7
}
}
if {${os.major} < 16} {
# We dropped support for these compilers on Sierra
lappend compilers macports-clang-3.4 macports-llvm-gcc-4.2 apple-gcc-4.2
}
# on PPC, only these compilers are useful at present
if {${configure.build_arch} eq "ppc" || ${configure.build_arch} eq "ppc64"} {
set compilers {gcc-4.2 apple-gcc-4.2 macports-gcc-6 macports-gcc-7}
}
return $compilers
}
===================
More information about the macports-dev
mailing list