Last active
May 16, 2024 21:31
-
-
Save grhkm21/3753bd3af9700e23f66772bc13e055ad to your computer and use it in GitHub Desktop.
Conda CC/CXX/FC compilers setup for Fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _tc_activation | |
set act_nature $argv[1] | |
set tc_prefix $argv[2] | |
set argv $argv[3..-1] | |
set pass | |
set from | |
set to | |
if test "$act_nature" = "activate" | |
set from "" | |
set to "CONDA_BACKUP_" | |
else | |
set from "CONDA_BACKUP_" | |
set to "" | |
end | |
for pass in check apply | |
for thing in $argv | |
switch "$thing" | |
case '*,*' | |
set newval (echo "$thing" | sed "s,^[^\,]*\,\(.*\),\1,") | |
set thing (echo "$thing" | sed "s,^\([^\,]*\)\,.*,\1,") | |
case '*' | |
set newval "$tc_prefix$thing" | |
set thing (echo $thing | tr 'a-z+-' 'A-ZX_') | |
if test ! -x "$CONDA_PREFIX/bin/$newval" -a "$pass" = "check" | |
echo "ERROR: This cross-compiler package contains no program $CONDA_PREFIX/bin/$newval" | |
return 1 | |
end | |
end | |
if test "$pass" = "apply" | |
set oldval (eval echo \$$from$thing) | |
if test -n "$oldval" | |
set -gx $to$thing $oldval | |
else | |
set -e $to$thing | |
end | |
if test -n "$newval" | |
set -gx $from$thing $newval | |
else | |
set -e $from$thing | |
end | |
end | |
end | |
end | |
return 0 | |
end | |
function activate_clang | |
set -gx CFLAGS_USED "-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem $CONDA_PREFIX/include" | |
set -gx DEBUG_CFLAGS_USED "-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fvar-tracking-assignments -ffunction-sections -pipe -isystem $CONDA_PREFIX/include" | |
set -gx CPPFLAGS_USED "-DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem $PREFIX/include" | |
set -gx DEBUG_CPPFLAGS_USED "-D_DEBUG -D_FORTIFY_SOURCE=2 -Og -isystem $CONDA_PREFIX/include" | |
set -gx LDFLAGS_USED "-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,$CONDA_PREFIX/lib -Wl,-rpath-link,$CONDA_PREFIX/lib -L$CONDA_PREFIX/lib" | |
set -gx CMAKE_PREFIX_PATH_USED "$PREFIX:$CONDA_PREFIX/x86_64-conda-linux-gnu/sysroot/usr" | |
set -gx _CMAKE_ARGS "-DCMAKE_AR=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-ar -DCMAKE_CXX_COMPILER_AR=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_C_COMPILER_AR=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ar" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_RANLIB=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-ranlib -DCMAKE_CXX_COMPILER_RANLIB=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_C_COMPILER_RANLIB=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-gcc-ranlib" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_LINKER=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-ld -DCMAKE_STRIP=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-strip" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release" | |
set -gx _MESON_ARGS "--buildtype release" | |
set -gx CC x86_64-conda-linux-gnu-cc | |
set -gx CPPFLAGS $CPPFLAGS_USED | |
set -gx CFLAGS $CFLAGS_USED | |
set -gx LDFLAGS $LDFLAGS_USED | |
set -gx DEBUG_CFLAGS $DEBUG_CFLAGS_USED | |
set -gx _CONDA_PYTHON_SYSCONFIGDATA_NAME "_sysconfigdata_x86_64_conda_cos6_linux_gnu" | |
set -gx CMAKE_PREFIX_PATH $CMAKE_PREFIX_PATH_USED | |
_tc_activation \ | |
activate x86_64-conda-linux-gnu- "HOST,x86_64-conda-linux-gnu" "BUILD,x86_64-conda-linux-gnu" \ | |
"CONDA_TOOLCHAIN_HOST,x86_64-conda-linux-gnu" \ | |
"CONDA_TOOLCHAIN_BUILD,x86_64-conda-linux-gnu" \ | |
cc cpp gcc gcc-ar gcc-nm gcc-ranlib \ | |
"CPPFLAGS,$CPPFLAGS_USED$CPPFLAGS$CPPFLAGS:-" \ | |
"CFLAGS,$CFLAGS_USED$CFLAGS$CFLAGS:-" \ | |
"LDFLAGS,$LDFLAGS_USED$LDFLAGS$LDFLAGS:-" \ | |
"DEBUG_CPPFLAGS,$DEBUG_CPPFLAGS_USED$DEBUG_CPPFLAGS$DEBUG_CPPFLAGS:-" \ | |
"DEBUG_CFLAGS,$DEBUG_CFLAGS_USED$DEBUG_CFLAGS$DEBUG_CFLAGS:-" \ | |
"CMAKE_PREFIX_PATH,$CMAKE_PREFIX_PATH_USED" \ | |
"_CONDA_PYTHON_SYSCONFIGDATA_NAME,$_CONDA_PYTHON_SYSCONFIGDATA_NAME_USED" \ | |
"CONDA_BUILD_SYSROOT,$CONDA_PREFIX/x86_64-conda-linux-gnu/sysroot" \ | |
"CONDA_BUILD_CROSS_COMPILATION," \ | |
"CC_FOR_BUILD,$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-cc" \ | |
"build_alias,x86_64-conda-linux-gnu" \ | |
"host_alias,x86_64-conda-linux-gnu" \ | |
"MESON_ARGS,$_MESON_ARGS" \ | |
"CMAKE_ARGS,$_CMAKE_ARGS" | |
set -e CONDA_BUILD_SYSROOT_TEMP | |
set -e _CMAKE_ARGS | |
end | |
function activate_clangxx | |
set -gx CXXFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $CONDA_PREFIX/include" | |
set -gx DEBUG_CXXFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -Og -g -Wall -Wextra -isystem $CONDA_PREFIX/include" | |
set -gx CXX "x86_64-conda-linux-gnu-c++" | |
set -gx CXXFLAGS $CXXFLAGS_USED | |
set -gx DEBUG_CXXFLAGS $DEBUG_CXXFLAGS_USED | |
_tc_activation \ | |
activate x86_64-conda-linux-gnu- \ | |
c++ g++ \ | |
"CXXFLAGS,$CXXFLAGS_USED$CXXFLAGS$CXXFLAGS:-" \ | |
"DEBUG_CXXFLAGS,$DEBUG_CXXFLAGS_USED$DEBUG_CXXFLAGS$DEBUG_CXXFLAGS:-" \ | |
"CXX_FOR_BUILD,$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-c++" | |
# echo $CXX | |
end | |
function activate_fortran | |
set -gx FFLAGS_USED "-march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem $CONDA_PREFIX/include" | |
set -gx FFLAGS $FFLAGS_USED | |
set -gx FORTRANFLAGS $FFLAGS_USED | |
set -gx DEBUG_FFLAGS "$FFLAGS_USED -march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments" | |
set -gx FORTRANFLAGS "$FFLAGS_USED -march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments" | |
_tc_activation \ | |
activate x86_64-conda-linux-gnu- \ | |
gfortran f95 \ | |
"FC_FOR_BUILD,$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-gfortran" \ | |
"FFLAGS,$FFLAGS_USED$FFLAGS$FFLAGS:-" \ | |
"FORTRANFLAGS,$FFLAGS_USED$FORTRANFLAGS$FORTRANFLAGS:-" \ | |
"DEBUG_FFLAGS,$FFLAGS_USED -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments -ffunction-sections -pipe$FFLAGS$FFLAGS:-" \ | |
"DEBUG_FORTRANFLAGS,$FFLAGS_USED -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments -ffunction-sections -pipe$FORTRANFLAGS$FORTRANFLAGS:-" \ | |
set -gx FC $GFORTRAN | |
set -gx F77 $GFORTRAN | |
set -gx F90 $GFORTRAN | |
_tc_activation \ | |
activate x86_64-conda-linux-gnu- \ | |
"FC,$FC" \ | |
"F77,$F77" \ | |
"F90,$F90" \ | |
"F95,$F95" | |
end | |
activate_clang | |
activate_clangxx | |
activate_fortran |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _tc_activation | |
set act_nature $argv[1] | |
set tc_prefix $argv[2] | |
set argv $argv[3..-1] | |
set pass | |
set from | |
set to | |
if test "$act_nature" = "activate" | |
set from "" | |
set to "CONDA_BACKUP_" | |
else | |
set from "CONDA_BACKUP_" | |
set to "" | |
end | |
for pass in check apply | |
for thing in $argv | |
switch "$thing" | |
case '*,*' | |
set newval (echo "$thing" | sed "s,^[^\,]*\,\(.*\),\1,") | |
set thing (echo "$thing" | sed "s,^\([^\,]*\)\,.*,\1,") | |
case '*' | |
set newval "$tc_prefix$thing" | |
set thing (echo $thing | tr 'a-z+-' 'A-ZX_') | |
if test ! -x "$CONDA_PREFIX/bin/$newval" -a "$pass" = "check" | |
echo "ERROR: This cross-compiler package contains no program $CONDA_PREFIX/bin/$newval" | |
return 1 | |
end | |
end | |
if test "$pass" = "apply" | |
set oldval (eval echo \$$from$thing) | |
if test -n "$oldval" | |
set -gx $to$thing $oldval | |
else | |
set -e $to$thing | |
end | |
if test -n "$newval" | |
set -gx $from$thing $newval | |
else | |
set -e $from$thing | |
end | |
end | |
end | |
end | |
return 0 | |
end | |
function activate_clang | |
set -gx CFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem $CONDA_PREFIX/include" | |
set -gx DEBUG_CFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra -isystem $CONDA_PREFIX/include" | |
set -gx LDFLAGS_USED "-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,$CONDA_PREFIX/lib -L$CONDA_PREFIX/lib" | |
set -gx LDFLAGS_LD_USED "-pie -headerpad_max_install_names -dead_strip_dylibs -rpath $CONDA_PREFIX/lib -L$CONDA_PREFIX/lib" | |
set -gx CPPFLAGS_USED "-D_FORTIFY_SOURCE=2 -isystem $CONDA_PREFIX/include" | |
set -gx CMAKE_PREFIX_PATH_USED "$CMAKE_PREFIX_PATH:$CONDA_PREFIX" | |
set -gx _CMAKE_ARGS "-DCMAKE_AR=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_CXX_COMPILER_AR=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_C_COMPILER_AR=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-ar" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_RANLIB=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_CXX_COMPILER_RANLIB=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_C_COMPILER_RANLIB=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-ranlib" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_LINKER=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-ld -DCMAKE_STRIP=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-strip" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_INSTALL_NAME_TOOL=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-install_name_tool" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_LIBTOOL=$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-libtool" | |
set -gx _CMAKE_ARGS "$_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=$CONDA_BUILD_SYSROOT_TEMP" | |
set -gx _MESON_ARGS "--buildtype release" | |
set -gx CC x86_64-apple-darwin13.4.0-clang | |
set -gx OBJC x86_64-apple-darwin13.4.0-clang | |
set -gx CPPFLAGS $CPPFLAGS_USED | |
set -gx CFLAGS $CFLAGS_USED | |
set -gx LDFLAGS $LDFLAGS_USED | |
set -gx LDFLAGS_LD $LDFLAGS_LD_USED | |
set -gx DEBUG_CFLAGS $DEBUG_CFLAGS_USED | |
set -gx _CONDA_PYTHON_SYSCONFIGDATA_NAME "_sysconfigdata_x86_64_apple_darwin13_4_0" | |
set -gx CMAKE_PREFIX_PATH $CMAKE_PREFIX_PATH_USED | |
_tc_activation \ | |
activate x86_64-apple-darwin13.4.0- "HOST,x86_64-apple-darwin13.4.0" \ | |
"CONDA_TOOLCHAIN_HOST,x86_64-apple-darwin13.4.0" \ | |
"CONDA_TOOLCHAIN_BUILD,x86_64-apple-darwin13.4.0" \ | |
ar as checksyms install_name_tool libtool lipo nm nmedit otool \ | |
pagestuff ranlib redo_prebinding seg_addr_table seg_hack segedit size strings strip \ | |
clang ld \ | |
"CC,$CC" \ | |
"OBJC,$OBJC" \ | |
"CC_FOR_BUILD,$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-clang" \ | |
"OBJC_FOR_BUILD,$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-clang" \ | |
"CPPFLAGS,$CPPFLAGS" \ | |
"CFLAGS,$CFLAGS" \ | |
"LDFLAGS,$LDFLAGS" \ | |
"LDFLAGS_LD,$LDFLAGS_LD" \ | |
"DEBUG_CFLAGS,$DEBUG_CFLAGS" \ | |
"_CONDA_PYTHON_SYSCONFIGDATA_NAME,$_CONDA_PYTHON_SYSCONFIGDATA_NAME" \ | |
"CMAKE_PREFIX_PATH,$CMAKE_PREFIX_PATH" \ | |
"CONDA_BUILD_CROSS_COMPILATION," \ | |
"SDKROOT,$CONDA_BUILD_SYSROOT_TEMP" \ | |
"CMAKE_ARGS,$_CMAKE_ARGS" \ | |
"MESON_ARGS,$_MESON_ARGS" \ | |
"ac_cv_func_malloc_0_nonnull,yes" \ | |
"ac_cv_func_realloc_0_nonnull,yes" \ | |
"host_alias,x86_64-apple-darwin13.4.0" \ | |
"build_alias,x86_64-apple-darwin13.4.0" \ | |
"BUILD,x86_64-apple-darwin13.4.0" | |
set -e CONDA_BUILD_SYSROOT_TEMP | |
set -e _CMAKE_ARGS | |
end | |
function activate_clangxx | |
set -gx CXXFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $CONDA_PREFIX/include" | |
set -gx DEBUG_CXXFLAGS_USED "-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -Og -g -Wall -Wextra -isystem $CONDA_PREFIX/include" | |
set -gx CXX "x86_64-apple-darwin13.4.0-clang++" | |
set -gx CXXFLAGS $CXXFLAGS_USED | |
set -gx DEBUG_CXXFLAGS $DEBUG_CXXFLAGS_USED | |
_tc_activation \ | |
activate x86_64-apple-darwin13.4.0- \ | |
clang++ \ | |
"CXX,$CXX" \ | |
"CXX_FOR_BUILD,$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-clang++" \ | |
"CXXFLAGS,$CXXFLAGS" \ | |
"DEBUG_CXXFLAGS,$DEBUG_CXXFLAGS" | |
echo $CXX | |
end | |
function activate_fortran | |
set -gx FFLAGS_USED "-march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem $CONDA_PREFIX/include" | |
set -gx FFLAGS $FFLAGS_USED | |
set -gx FORTRANFLAGS $FFLAGS_USED | |
set -gx DEBUG_FFLAGS "$FFLAGS_USED -march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments" | |
set -gx FORTRANFLAGS "$FFLAGS_USED -march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments" | |
_tc_activation \ | |
activate x86_64-apple-darwin13.4.0- \ | |
gfortran \ | |
"FC_FOR_BUILD,$CONDA_PREFIX/bin/x86_64-apple-darwin13.4.0-gfortran" \ | |
"FFLAGS,$FFLAGS:-$FFLAGS" \ | |
"FORTRANFLAGS,$FFLAGS" \ | |
"DEBUG_FFLAGS,$DEBUG_FFLAGS" \ | |
"DEBUG_FORTRANFLAGS,$FORTRANFLAGS" | |
set -gx FC $GFORTRAN | |
set -gx F77 $GFORTRAN | |
set -gx F90 $GFORTRAN | |
set -gx F95 $GFORTRAN | |
_tc_activation \ | |
activate x86_64-apple-darwin13.4.0- \ | |
"FC,$FC" \ | |
"F77,$F77" \ | |
"F90,$F90" \ | |
"F95,$F95" | |
end | |
if test "$CONDA_BUILD_STATE" = "BUILD" -a "$target_platform" != "osx-64" | |
echo "Not activating environment because this compiler is not expected." | |
else | |
activate_clang | |
activate_clangxx | |
activate_fortran | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment