Skip to content

Commit

Permalink
Do not pass "-arch ppc" to GCC 4.7 - 6
Browse files Browse the repository at this point in the history
  • Loading branch information
evanmiller committed Dec 4, 2021
1 parent 563474f commit 2ac6824
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions src/port1.0/portconfigure.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ proc portconfigure::configure_get_archflags {tool} {
} elseif {[tbool configure.m32]} {
set flags "-m32"
} elseif {${configure.build_arch} ne ""} {
if {[arch_flag_supported ${configure.compiler}] &&
if {[arch_flag_supported ${configure.compiler} ${configure.build_arch}] &&
$tool in {cc cxx objc objcxx}
} then {
set flags "-arch ${configure.build_arch}"
Expand All @@ -503,7 +503,7 @@ proc portconfigure::configure_get_archflags {tool} {
# ld directly. So we punt and let portfiles deal with that case.
proc portconfigure::configure_get_ld_archflags {} {
global configure.build_arch configure.compiler
if {${configure.build_arch} ne "" && [arch_flag_supported ${configure.compiler}]} {
if {${configure.build_arch} ne "" && [arch_flag_supported ${configure.compiler} ${configure.build_arch}]} {
return "-arch ${configure.build_arch}"
} else {
return ""
Expand Down Expand Up @@ -700,20 +700,25 @@ proc portconfigure::configure_get_universal_archflags {} {
return $flags
}

# internal proc to determine if the compiler supports -arch
proc portconfigure::arch_flag_supported {compiler {multiple_arch_flags no}} {
if {${multiple_arch_flags}} {
return [regexp {^gcc-4|llvm|apple|clang} ${compiler}]
# internal proc to determine if the compiler supports a single -arch flag
# ppc is the default in the second arg because it is the least compatible with -arch
proc portconfigure::arch_flag_supported {compiler {build_arch "ppc"}} {
# GCC prior to 4.7 does not accept -arch flag
if {[regexp {^macports(?:-[^-]+)?-gcc-4\.[0-6]} ${compiler}]} {
return no
# GCC prior to 6 does not accept -arch flag for PPC
} elseif {[regexp {^macports(?:-[^-]+)?-gcc-[4-5]} ${compiler}] && [regexp {^ppc} ${build_arch}]} {
return no
} else {
# GCC prior to 4.7 does not accept -arch flag
if {[regexp {^macports(?:-[^-]+)?-gcc-4\.[0-6]} ${compiler}]} {
return no
} else {
return yes
}
return yes
}
}

# internal proc to determine if the compiler supports multiple -arch flags
proc portconfigure::multiple_arch_flags_supported {compiler} {
return [regexp {^gcc-4|llvm|apple|clang} ${compiler}]
}

proc portconfigure::compiler_port_name {compiler} {
set valid_compiler_ports {
{^apple-gcc-(\d+)\.(\d+)$} {apple-gcc%s%s}
Expand Down
2 changes: 1 addition & 1 deletion src/port1.0/portutil.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ proc universal_setup {args} {
ui_debug "OS doesn't support universal builds, so not adding the default universal variant"
} elseif {[llength [option configure.universal_archs]] <= 1} {
ui_debug "only one arch supported, so not adding the default universal variant"
} elseif {![portconfigure::arch_flag_supported [option configure.compiler] yes]} {
} elseif {![portconfigure::multiple_arch_flags_supported [option configure.compiler]]} {
ui_debug "Compiler doesn't support universal builds, so not adding the default universal variant"
} else {
ui_debug "adding the default universal variant"
Expand Down

0 comments on commit 2ac6824

Please sign in to comment.