Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
OpenBLAS[-devel]: fix +clang and +gcc* variants to not conflict; defa…
…ult to +clang (for C/C++) and +gcc6 (for Fortran). If -clang is selected, then the +gcc* variant is used as the compiler suite. Addresses ticket https://trac.macports.org/ticket/53348 .
  • Loading branch information
michaelld committed Feb 1, 2017
1 parent 15c587b commit cf680f7
Showing 1 changed file with 64 additions and 37 deletions.
101 changes: 64 additions & 37 deletions math/OpenBLAS/Portfile
Expand Up @@ -45,43 +45,80 @@ checksums rmd160 11f85eb4bb382e10298ac40d1e1fd4ecc46bb3da \

}

variant gcc45 conflicts gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 clang \
description "Use Gcc45 as compiler" {
configure.compiler macports-gcc-4.5
}
# declare +clang variant

variant clang description "Use Clang as C/C++ compiler (required for AVX)" {}

variant gcc46 conflicts gcc45 gcc47 gcc48 gcc49 gcc5 gcc6 clang \
description "Use Gcc46 as compiler" {
configure.compiler macports-gcc-4.6
# default to +clang if the processor has avx instructions
if {![catch {sysctl hw.optional.avx1_0} has_avx] && $has_avx == 1 &&
![variant_isset clang]} {
default_variants +clang
}

variant gcc47 conflicts gcc45 gcc46 gcc48 gcc49 gcc5 gcc6 clang \
description "Use Gcc47 as compiler" {
configure.compiler macports-gcc-4.7
# it is OK to use -clang, so don't check for that condition here

# declare +gcc* variants

set GCC_VERSIONS_NO_DOT {45 46 47 48 49 5 6 7}

foreach this_gcc_version_no_dot ${GCC_VERSIONS_NO_DOT} {
set ndx [lsearch -exact ${this_gcc_version_no_dot} ${this_gcc_version_no_dot}]
set this_conflicts [lreplace ${this_gcc_version_no_dot} ${ndx} ${ndx}]
if {[variant_isset clang]} {
set this_description "Use gcc${this_gcc_version_no_dot} as Fortran compiler"
} else {
set this_description "Use gcc${this_gcc_version_no_dot} for the compiler suite"
}
eval [subst {
variant gcc${this_gcc_version_no_dot} \
conflicts ${this_conflicts} \
description ${this_description} {}
}]
}

variant gcc48 conflicts gcc45 gcc46 gcc47 gcc49 gcc5 gcc6 clang \
description "Use Gcc48 as compiler" {
configure.compiler macports-gcc-4.8
# set default +gcc* variant: default to +gcc6 if not other +gcc*
# variant is selected. this variant is used for Fortran, no matter
# whether +clang is selected or not. if +clang is not selected or
# -clang is selected, then use the selected +gcc* variant for the
# compiler suite.

set GCC_VER_NO_DOT 0
foreach this_gcc_version_no_dot ${GCC_VERSIONS_NO_DOT} {
if {[variant_isset gcc${this_gcc_version_no_dot}]} {
set GCC_VER_NO_DOT ${this_gcc_version_no_dot}
break
}
}

variant gcc49 conflicts gcc45 gcc46 gcc47 gcc48 gcc5 gcc6 clang \
description "Use Gcc49 as compiler" {
configure.compiler macports-gcc-4.9
if {${GCC_VER_NO_DOT} == 0} {
default_variants +gcc6
}

variant gcc5 conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc6 clang \
description "Use Gcc5 as compiler" {
configure.compiler macports-gcc-5
# make sure -gcc6 was not selected alone

set GCC_VER_NO_DOT 0
foreach this_gcc_version_no_dot ${GCC_VERSIONS_NO_DOT} {
if {[variant_isset gcc${this_gcc_version_no_dot}]} {
set GCC_VER_NO_DOT ${this_gcc_version_no_dot}
break
}
}

variant gcc6 conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 clang \
description "Use Gcc6 as compiler" {
configure.compiler macports-gcc-6
if {${GCC_VER_NO_DOT} == 0} {
ui_error "\n\nYou must select a Fortran compiler variant; you cannot select -gcc6 alone.\n"
return -code error "Invalid variant selection."
}

variant clang conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 \
description "Use Clang as compiler" {
set GCC_VER_DOT [join [split ${GCC_VER_NO_DOT} ""] "."]

# set compilers to use

if {[variant_isset clang]} {

# use selected +gcc* for Fortran only
depends_build-append port:gcc${GCC_VER_NO_DOT}
configure.fc ${prefix}/bin/gfortran-mp-${GCC_VER_DOT}

if {[vercmp $xcodeversion 5.0] >= 0} {
configure.compiler clang
} else {
Expand All @@ -94,21 +131,11 @@ variant clang conflicts gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 \
configure.compiler macports-clang-3.4
}
}
depends_build-append port:gcc5
configure.fc ${prefix}/bin/gfortran-mp-5
} else {

}
# use selected +gcc* for the whole compiler suite
configure.compiler macports-gcc-${GCC_VER_DOT}

if {![variant_isset gcc45] && ![variant_isset gcc46] && ![variant_isset gcc47] && \
![variant_isset gcc48] && ![variant_isset gcc49] && ![variant_isset gcc5] && \
![variant_isset gcc6] && ![variant_isset clang]} {
if { ![catch {sysctl hw.optional.avx1_0} has_avx] && $has_avx == 1 } {
#Use clang if the processor has avx instructions
default_variants +clang
} else {
#Else, use gcc5 as default
default_variants +gcc5
}
}

variant lapack description "Add Lapack/CLapack support to the library" { }
Expand Down

0 comments on commit cf680f7

Please sign in to comment.