Skip to content

Commit

Permalink
Merge pull request #547 from galacticusorg/fixStaticBuilds
Browse files Browse the repository at this point in the history
Fix static builds of FSPS and CLASS
  • Loading branch information
abensonca authored Feb 2, 2024
2 parents 970b8cf + 64cf066 commit cf5713b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ jobs:
forutilsVersion=`awk '{if ($1 == "forutils:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml`
fspsVersion=`awk '{if ($1 == "fsps:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml`
cloudyVersion=`awk '{if ($1 == "cloudy:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml`
# Check that executables were statically linked
! ldd dynamic/CAMB-${cambVersion}/fortran/camb
! ldd dynamic/AxionCAMB/camb
! ldd dynamic/class_public-${classVersion}/class
! ldd dynamic/RecFast/recfast.exe
! ldd dynamic/fsps-${fspsVersion}/src/autosps.exe
tar cfj tools.tar.bz2 \
dynamic/CAMB-${cambVersion}/fortran/camb \
dynamic/AxionCAMB/camb \
Expand Down
2 changes: 1 addition & 1 deletion source/interface.CLASS.F90
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ subroutine Interface_CLASS_Initialize(classPath,classVersion,static)
call displayMessage("compiling CLASS code",verbosityLevelWorking)
command='cd '//classPath//'; cp Makefile Makefile.tmp; '
! Include Galacticus compilation flags here.
command=command//'sed -E -i~ s/"^CC[[:space:]]+=[[:space:]]+gcc"/"CC='//char(compiler(languageC))//'"/ Makefile.tmp; sed -E -i~ s/"^CCFLAG = "/"CCFLAG = '//char(stringSubstitute(compilerOptions(languageC),"/","\/"))
command=command//'sed -E -i~ s/"^CC[[:space:]]+=[[:space:]]+gcc"/"CC='//char(compiler(languageC))//'"/ Makefile.tmp; sed -E -i~ s/"^(CC|LD)FLAG = "/"\1FLAG = '//char(stringSubstitute(compilerOptions(languageC),"/","\/"))
if (static_) command=command//' -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive'
command=command//' "/ Makefile.tmp; make -f Makefile.tmp -j1 class'
call System_Command_Do(char(command),status);
Expand Down
19 changes: 17 additions & 2 deletions source/interface.FSPS.F90
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,25 @@ subroutine Interface_FSPS_Initialize(fspsPath,fspsVersion,static)
end if
call displayMessage("compiling autosps.exe code",verbosityLevelWorking)
if (static_) then
call System_Command_Do("cd "//fspsPath//"/src; sed -i~ -E s/'^(F90FLAGS = .*)'/'\1 \-static'/g Makefile")
call System_Command_Do( &
& "cd "//fspsPath//"/src; " // &
#ifndef __APPLE__
& "grep -P '^F90FLAGS := ' Makefile && " // &
#endif
& "sed -i~ -E s/'^(F90FLAGS := [^#]*)'/'\1 \-static'/g Makefile" , &
& status &
& )
else
call System_Command_Do("cd "//fspsPath//"/src; sed -i~ -E s/'^(F90FLAGS = .*)[[:space:]]*\-static(.*)'/'\1 \2'/g Makefile")
call System_Command_Do( &
& "cd "//fspsPath//"/src; " // &
#ifndef __APPLE__
& "grep -P '^F90FLAGS := ' Makefile && " // &
#endif
& "sed -i~ -E s/'^(F90FLAGS := .*)[[:space:]]*\-static(.*)'/'\1 \2'/g Makefile", &
& status &
& )
end if
if (status /= 0) call Error_Report("failed to patch FSPS file 'Makefile' for static/dynamic build"//{introspection:location})
call System_Command_Do( &
& "cd "//fspsPath//"/src; export SPS_HOME="//fspsPath//'; export F90FLAGS="' // &
#ifndef __aarch64__
Expand Down

1 comment on commit cf5713b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Milky Way model benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: cf5713b Previous: 970b8cf Ratio
Milky Way model - Likelihood - localGroupStellarMassHaloMassRelation 14.000613786469 -logℒ 8.61735255527312 -logℒ 1.62

This comment was automatically generated by workflow using github-action-benchmark.

CC: @abensonca

Please sign in to comment.