2 ##############################################################################
3 # charmc: Compiler for Converse/Charm/Charm++ programs
5 # Converted to Bourne Shell by Orion Sky Lawlor, 10/21/1999
7 # Initialize the main controlling variables, setup error handler
8 # ALL variables used by this script should be initialized here.
10 ##############################################################################
12 #Prepare aliases for the external commands we use--
13 # Note that adding /bin/ to everything breaks Cygwin32.
42 #Generic options, passed to everything
45 #charm internal flag, only pass to c and cxx, not f90
46 OPTS_CPP_INTERNAL
="-D__CHARMC__=1"
61 EXPLICIT_COMPILATION
="no"
100 ROSE_OMP_TLS_GLOBALS
="no"
101 PRINT_BUILDING_BLOCKS
=""
104 TAU_MAKEFILE
=Make.tau
118 ####################################################################
120 # Utility routines used below
122 ###################################################################
124 # PrintUsage: prints a helpful command-line usage message and quits
125 # Args: any additional messages
129 echo "Usage: charmc [ flags ] <files>"
132 echo " -o <target> -g -O"
133 echo " -D<define> -I<include path> -L<lib path> -l<library> -s"
134 echo " -machine <mach> -seq -host -language <lang> -pg <opt>"
135 echo " -balance <mode> -tracemode <mode> -memory <mode>"
136 echo " -modules <comma-separated list of C++ modules> -thread"
137 echo " -debug-script -count-tokens -default-to-aout -E -S -M"
138 echo " -verbose -save -purify -cp <dest> -cpmod -gen-cpm <pkg>"
139 echo " -swapglobals -tlsglobals -roseomptlsglobals"
140 echo " -use-reliable-cc -use-fastest-cc -use-new-std"
141 echo " -cc <new cc> -c++ <new CC> -ld <new ld> -ld++ <new LD>"
142 echo " -cpp-option <opt> -ldro-option <opt> -cc-option <opt>"
143 echo " -c++-option <opt> -ld-option <opt> -ld++-option <opt>"
144 echo " -f90 <new f90> -f90-option <opt> -fmoddir <f90mod path>"
145 echo " -flibs -rpath <path> -custom-part -touch-on-failure"
146 echo " -mpi -openmp -no-trace-mpi -build-shared -charm-shared"
147 echo " -no-charmrun -no-preprocess-ci -nomain-module -nomain"
148 echo " -nof90main -f90main"
150 echo " Charmc compiles C, C++, f77, f90, AMPI, Converse, Converse++, Charm, "
151 echo "and Charm++ programs. The flags generally match those of cc or f77."
152 echo " Other options that are not listed here will be passed directly to the"
153 echo "underlying compiler and/or linker."
154 echo "Parallel Programming Lab, UIUC, 2018."
159 # End blows away the temporary files (unless SAVE is true) and exits
164 for FILE
in `echo $FILES`
166 #BASE=`stripExtention $FILE`
167 MYTMP
=`basename $FILE`".TMP"
168 $RM $MYTMP.P.C
$MYTMP.cpp
$MYTMP.space
$MYTMP.xlat
$MYTMP.o
169 $RM $MYTMP.c
$MYTMP.c
.0.h
$MYTMP.c
.1.h
$MYTMP.c
.2.h
170 $RM $MYTMP.i
$MYTMP.
$CMK_CPP_SUFFIX
173 if [ -z "$SKIP_MODULEINIT" -a -n "$modInitObj" ]
175 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
176 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
182 # Write this error message to stderr
183 # ("1>&2" redirects the echo output to stderr).
188 # This procedure prints an error message and exits.
189 # Args: written to stderr
191 Warning
"Fatal Error by charmc in directory "`pwd`
193 Warning
"charmc exiting..."
198 # Instead of an ECHO_CMD variable, I define a procedure Do,
199 # which (possibly) echos, runs, and tests the errors of the given command.
200 # Args: executed as given
202 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
209 # The UNIX result code better be zero, or we die
210 [ $Do_res -eq 0 -o -n "$NOABORT" ] || Abort
"Command $@ returned error code $Do_res"
213 # This procedure removes the extention (the ".c" in "./main.c") from
214 # its first argument, and prints the result. Unlike the builtin command
215 # basename, it keeps the directory path.
216 # Args: <name to strip>
218 se_base
=`basename $1`
219 # se_base=`echo $1 | awk -F/ '{print $NF}'`
220 se_strip
=`echo $se_base | awk -F. '{ORS="";print $1;for (i=2;i<NF;i++) print "."$i}'`
221 se_ret
=`echo $1 | awk -F/ '{ORS="";for (i=1;i<NF;i++) print $i"/"}'`"$se_strip"
225 # GetExtention returns the extention on the given file name
226 # or "" if none. (e.g. "./bob/snack.c" returns ".c")
227 # Args: <name to find extention of>
229 # se_base=`echo $1 | awk -F/ '{print $NF}'`
230 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
232 se_ret
=`echo $1 | sed -e 's/.*\././'`
233 if test "$se_ret" = $1
242 [ -n "$VERBOSE" ] && echo "charmc>" $@
246 if [ -n "$DEBUG_SCRIPT" ]
249 echo "------- Charmc Debugging info: $* -------"
250 echo "CHARMBIN=$CHARMBIN"
251 echo "CHARMINC=$CHARMINC"
252 echo "CHARMLIB=$CHARMLIB"
254 echo "DELETE=$DELETE"
255 echo "OBJECT=$OBJECT"
256 echo "LANGUAGE=$LANGUAGE"
257 echo "PARADIGM=$PARADIGM"
258 # echo "Working directory="`pwd`
262 # Return success if $1 is not in any of the other arguments
268 if [ "$search" = "$1" ]
270 # It's already in there-- fail
275 # It's missing--succeed
279 # Add arguments to our modules list, avoiding duplicates
283 notInList
$M $MODULES && MODULES
="$MODULES $M"
287 # Add this word to this list, avoiding duplicates
302 # Drop the first argument anywhere it appears in the subsequent list
310 if [ "$1" != "$drop" ]; then
319 # TEMP_BASE is appended with this script's process ID (PID),
320 # so multiple charmcs can run in parallel without overwriting
321 # each other's temporary files.
322 TEMP_BASE
="/tmp/charmc_tmp.$$"
324 # Try to find CHARMBIN by looking in directory where charmc is
326 if [ -z "$CHARMBIN" ]
329 CHARMBIN
=`dirname $SCRIPT`
330 # CHARMBIN=`cd $CHARMBIN; pwd`
331 # NOTE: this script no longer tries to follow soft links
332 # to find the "original" charmc-- if this is bad,
333 # translate these lines to Bourne shell from C shell:
334 # -------------------- Begin C Shell ------------------------->
335 # if ($SCRIPT:h != $SCRIPT:t) then
337 # set SCRIPT=$SCRIPT:t
339 # foreach dir ($path)
340 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
346 # while (x`find $SCRIPT -type l -print` == x$SCRIPT)
347 # set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
348 # if ($SCRIPT:h != $SCRIPT:t) then
350 # set SCRIPT=$SCRIPT:t
354 # <------------------ End C Shell -----------------------------
361 version
=`cat $CHARMBIN/../include/VERSION`
362 echo Charm
++ Version
$version
366 ##############################################################################
368 # The following section identifies CHARMBIN, the charm binary-directory.
370 ##############################################################################
374 # Try to find CHARMBIN by looking in directory where charmc is
379 FIRST_THREE
=`uname -s | awk '{print substr($1,1,3)}' `
380 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
382 # Running on a windows system-- append .exe to file names
386 CHARMLIB
="$CHARMBIN/../lib"
387 CHARMINC
="$CHARMBIN/../include"
389 if test -d "$CHARMBIN/../lib_so"
391 CHARMLIBSO
=`cd $CHARMBIN/../lib_so 2>/dev/null && pwd`
392 #getting absolute path is harder than thought because of symbolic links and ..
393 #ksh needs cd -P to resolve werid symbolic links, however -P is not portable
394 #csh is ok too if it exists
395 test -z "$CHARMLIBSO" && CHARMLIBSO
=`cd -P $CHARMBIN/../lib_so 2>/dev/null && pwd`
396 test -z "$CHARMLIBSO" && CHARMLIBSO
=`csh -c "cd $CHARMBIN/../lib_so >& /dev/null && pwd"`
397 test -z "$CHARMLIBSO" && echo "$CHARMBIN/../lib_so: not found" && exit 1
400 ##############################################################################
402 # Parse the arguments
404 # Don't do any analysis in here, just the parsing.
406 ##############################################################################
408 [ $# -eq 0 ] && printUsage
"Error: No arguments given."
437 SKIP_MODULEINIT
="yes"
441 # Parse out some fake languages (that are actually modules)
443 "ampi") AddModules tcharmmain ampi
;;
444 "ampif") AddModules tcharmmain ampif
; USE_F90_LIBRARIES
="1" ; AMPIF
="1" ;;
445 "armci") AddModules tcharmmain armci
;;
446 "armcif") AddModules tcharmmain armci
; USE_F90_LIBRARIES
="1" ;;
447 "fem") AddModules tcharmmain fem
; AMPIMAIN
="femmain";;
448 "femf") AddModules tcharmmain fem
; AMPIMAIN
="femmain"; USE_F90_LIBRARIES
="1" ;;
449 "ParFUM_TOPS") AddModules tcharmmain ParFUM ParFUM_TOPS
; AMPIMAIN
="ParFUMmain";;
450 "ParFUM") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain";;
451 "ParFUMf") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain"; USE_F90_LIBRARIES
="1" ;;
452 "mblock") AddModules tcharmmain mblock
;;
453 "mblockf") AddModules tcharmmain mblock
; USE_F90_LIBRARIES
="1" ;;
455 "charm"|
"charm++"|
"charm++f"|
"f90charm"|
"converse"|
"converse++"|
"bgcharm++"|
"bgconverse++"|
"bluegene"|
"ckbluegene"|
"bigsim")
469 # Requested support from charmdebug: add some modules and libraries
474 "-module"|
"-modules")
475 AddModules
`echo $1 | sed -e 's/,/ /g'`
481 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
482 BALANCER
="$BALANCER $1"
483 mod
=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
494 Warning
"Warning: -queue currently being ignored."
509 TRACEMODE_NEW
=`AddList $TRACEMODE $1`
510 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
512 Warning
"Warning: Duplicate tracemode $1 ignored"
514 TRACEMODE
=$TRACEMODE_NEW
522 "-swapglobal"|
"-swapglobals")
527 "-tlsglobal"|
"-tlsglobals")
531 "-roseomptlsglobals")
532 ROSE_OMP_TLS_GLOBALS
="yes"
536 echo "Verbose mode set"
545 SPU_EXTRA_LIBS
="$SPU_EXTRA_LIBS -l$1"
554 echo "Will give excessive charmc debugging output..."
600 OPTS_CPP
="$OPTS_CPP $1"
605 OPTS_LDRO
="$OPTS_LDRO $1"
610 OPTS_CC
="$OPTS_CC $1"
615 OPTS_CXX
="$OPTS_CXX $1"
620 OPTS_F90
="$OPTS_F90 $1"
624 "-ld-option"|
"-ld++-option")
625 OPTS_LD
="$OPTS_LD $1"
630 OPTS_LD
="$OPTS_LD -rpath $1"
638 "-fortran"|
"-flib"|
"-flibs")
639 USE_F90_LIBRARIES
="1"
644 "-fortran77"|
"-f77lib"|
"-f77libs")
645 USE_F77_LIBRARIES
="1"
648 # Run preprocessor only
654 # Run preprocessor as an extra step, continue after preprocessing
658 # Turn off the preprocessor for ci files
662 # Run preprocessor/assembler only
666 #------ Dependency generation ---------
667 "-M" |
"-MM" |
"-MMD" |
"-MG")
672 "-MF" |
"-MT" |
"-MQ" |
"-MD") #-MP will pass through automatically
676 #--------------------------------------
682 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
688 echo $arg | cut
-d'=' -f2
692 if [ "$EXPLICIT_OBJECT" = "no" ]
696 EXPLICIT_COMPILATION
="yes"
700 EXPLICIT_OBJECT
="yes"
711 MODCOPIES
="$1 $MODCOPIES"
721 OPTS_CPP
="$OPTS_CPP -I$1"
726 if echo "$arg" |
grep ' ' > /dev
/null
2>/dev
/null
728 OPTS_CPP
="$OPTS_CPP "\"$arg\"
730 OPTS_CPP
="$OPTS_CPP $arg"
751 Warning
"passing unrecognized option $arg to all compilers and linkers"
757 -L*|
-shared|
-G) # note that this is not executed if $arg == -shared|-G, due to the case above; might be a bug
758 OPTS_LD
="$OPTS_LD $arg"
764 # used internally when building Charm++ to create lib_so
768 # used internally not to build Charm++ lib_so
783 PRODUCTION_MODE
=false
787 POST_LIBRARIES
="$POST_LIBRARIES $arg"
795 F90_MODDIR
="$F90_MODDIR $1"
799 -l*|
*.a|
*.so|
*.so.
*|
*.dylib
)
800 if [ -n "$POST_LANGUAGE" ]
802 POST_LIBRARIES
="$POST_LIBRARIES $arg"
804 PRE_LIBRARIES
="$PRE_LIBRARIES $arg"
810 LINK_WHOLE_ARCHIVE
=true
818 OPTS_LD
="$OPTS_LD $arg"
836 MPI_INTEROPERATE
="yes"
846 CUSTOM_PARTITION
="yes"
854 SKIP_MODULEINIT
="yes"
857 -print-building-blocks)
858 PRINT_BUILDING_BLOCKS
="yes"
859 SKIP_MODULEINIT
="yes"
867 # Warning "passing unrecognized option $arg to all compilers and linkers"
871 [ -n "$VERBOSE" ] && echo "Adding file $arg..."
877 # printUsage "Error: Unrecognized argument $arg"
878 # Warning "passing unrecognized option $arg to all compilers and linkers"
887 # Process original command-line arguments
888 eval processArgs
"$@"
890 # Do not skip linking if user explicitly specified an output file
891 # This allows generating dependencies while compiling
892 if [ "$GENDEPENDS" = "yes" -a "$EXPLICIT_OBJECT" = "yes" ]; then
896 USER_POST_LIBRARIES
="$POST_LIBRARIES"
897 USER_PRE_LIBRARIES
="$PRE_LIBRARIES"
899 # Construct list of object files
900 numFiles
=`echo $FILES | wc -w`
905 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
906 OBJECTFILES
="$OBJECTFILES $FILE"
908 *.c|
*.s|
*.S|
*.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu|
*.f|
*.F|
*.f77|
*.F77|
*.f90|
*.F90|
*.fpp|
*.FPP
)
909 BASE
=`stripExtention \`basename $FILE\
``
912 if [ $numFiles = 1 -a -n "$OBJECT" ]
914 OBJ_EXT
=`getExtention $OBJECT`
915 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
921 # Handle new object files
922 if [ -n "$BASEO" -a -n "$OBJECT" ]
924 if [ "$OBJECT" != "$BASEO" ]
926 DELETE
="$DELETE $BASEO"
928 OBJECTFILES
="$OBJECTFILES $BASEO"
935 ##############################################################################
937 # Load module dependencies.
939 ##############################################################################
941 Debug
"About to read machine config script"
942 Debug
"Read config script, setting defaults..."
944 [ ! -r $CHARMINC/conv-config.sh
] && Abort
"Cannot find conv-config.sh in $CHARMINC"
945 .
$CHARMINC/conv-config.sh
$CHARMINC
947 Debug
"Setting vars..."
949 if [ "$USE_BUILD_OPTIONS" = "1" ]
951 [ -n "$VERBOSE" ] && echo "Charmc applying build time options: $BUILDOPTS"
952 OPTS
="$OPTS $BUILDOPTS"
955 # If we are debugging, add "-g -O0" to the C/C++ flags
956 if [ -n "$CHARMDEBUG" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]; then
957 if [ -n "$CMK_BUILD_PYTHON" ]; then
958 AddModules PythonCCS charmdebug_python
959 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lpython${CMK_BUILD_PYTHON}`
961 OPTS_CPP
="$OPTS_CPP -O0 -g"
964 # The purpose of the -rpath-origin option is for the resulting binary to have
965 # the literal text '$ORIGIN' in the RPATH field of its ELF header, essentially
966 # saying that it is okay for the binary to look in the same directory as itself
967 # for the shared objects it needs. Unfortunately, POSIX shells will interpret
968 # this text as a variable instead of passing in the string itself, requiring
969 # the string to be escaped.
970 # Additionally, some platforms do not need any special parameters.
971 if [ -n "$RPATH_ORIGIN" -a "$CMK_MACOSX" != "1" -a "$CMK_COMPILER" != "msvc" ]; then
972 OPTS_LD
="$OPTS_LD '-Wl,-rpath,\$ORIGIN'"
977 if [ "$WERROR" = "1" ]
979 OPTS
="$OPTS $CMK_WARNINGS_ARE_ERRORS"
982 # If the user has asked for the latest language standards (C11 or CPP11)
983 if [ "$USE_NEW_STD" = "1" ]
985 # and if configure confirmed that the underlying compiler knows abt C11, enable it
986 if [ "$CMK_COMPILER_KNOWS_C11" = "1" ]
988 OPTS_CC
="$OPTS $CMK_ENABLE_C11"
992 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
997 if [ ! -x "$CMK_ROSE_OMP_TOOL" ]
999 Abort
"The environment variable CMK_ROSE_OMP_TOOL must contain the path to a built binary of the ROSE OpenMP variable privatization tool"
1003 if [ "$USE_OPENMP" = "yes" -o "$CMK_OMP" = "1" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]
1005 if [ "$CMK_HAS_OPENMP" != "1" ]
1007 echo "Error: OpenMP is unavailable!"
1010 [ -n "$VERBOSE" ] && echo OpenMP support enabled
1011 OPTS_CC
="$OPTS_CC $CMK_C_OPENMP"
1012 OPTS_CXX
="$OPTS_CXX $CMK_C_OPENMP"
1013 OPTS_F90
="$OPTS_F90 $CMK_F_OPENMP"
1014 OPTS_LD
="$OPTS_LD $CMK_LD_OPENMP"
1016 [ -n "$VERBOSE" ] && echo OpenMP support not enabled
1019 if [ "$TLSGLOBALS" = "1" ]
1021 OPTS_CC
="$OPTS_CC -mno-tls-direct-seg-refs -ftls-model=initial-exec"
1022 OPTS_CXX
="$OPTS_CXX -mno-tls-direct-seg-refs -ftls-model=initial-exec"
1023 OPTS_F90
="$OPTS_F90 -mno-tls-direct-seg-refs -ftls-model=initial-exec"
1026 # Look up and add the dependencies for module $1
1029 notInList
$M $PROCESSED_MODULES ||
return
1030 PROCESSED_MODULES
="$PROCESSED_MODULES $M"
1031 #PRE_LIBRARIES=`AddList $PRE_LIBRARIES -lmodule$M`
1032 PRE_LIBRARIES
=`AddList -lmodule$M $PRE_LIBRARIES`
1033 # HACK: add modules to both ends of library list, to avoid
1034 # undefined symbol CkRegisterMainModule when it's in a module file.
1035 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lmodule$M`
1036 if [ "$M" = "PythonCCS" ]
1042 # fixme: should search everything in the -L library paths:
1043 for dir
in `echo . $CHARMLIB`
1045 d
="$dir/libmodule$M.dep"
1046 [ -r "$d" ] && dep
=$d
1050 # Add the module dependencies in this file
1051 # Debugf "Adding module" $M "dependencies from" $dep
1053 Debugf
"Module" $M "adds dependencies:" $deps
1058 # Repeat the module-dependency search until we find no
1061 while [ "$START_MODULES" != "$MODULES" ]
1063 Debugf
"----------- Module dependency search ------------"
1064 START_MODULES
="$MODULES"
1071 Debugf
"----------- Module dependency search complete ------------"
1075 ##############################################################################
1077 # Load machine-specific configuration data, then handle overrides to it.
1079 ##############################################################################
1082 if [ x
"$CMK_NO_BUILD_SHARED" = "xfalse" ]
1087 if [ "$BUILD_SHARE" = "1" ]
1093 if [ "$USE_PIC" = "1" ]
1095 OPTS_CC
="$OPTS_CC $OPTS_PIC"
1096 OPTS_CXX
="$OPTS_CXX $OPTS_PIC"
1097 OPTS_F90
="$OPTS_F90 $OPTS_PIC"
1098 OPTS_LD
="$OPTS_LD $OPTS_PIC"
1101 if [ "$BUILD_SHARE" = "1" ]
1103 # ignore BUILD_SHARE if the target is not .a or .so
1105 *.a|
*.so|
*.so.
*|
*.sl|
*.dylib
)
1106 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO"
1107 [ -n "$CHARMLIBSO" ] && OPTS_LD
="$OPTS_LD -L$CHARMLIBSO"
1115 if [ -n "$OVERRIDE_CC" ]
1117 CMK_CC
="$OVERRIDE_CC"
1120 if [ -n "$OVERRIDE_CXX" ]
1122 CMK_CXX
="$OVERRIDE_CXX"
1125 if [ -n "$OVERRIDE_F90" ]
1127 CMK_CF90
="$OVERRIDE_F90"
1130 if [ -n "$OVERRIDE_LD" ]
1132 CMK_LD
="$OVERRIDE_LD"
1135 if [ -n "$OVERRIDE_LDXX" ]
1137 CMK_LDXX
="$OVERRIDE_LDXX"
1140 if [ -n "$USE_RELIABLE_CC" ]
1142 CMK_CC
="$CMK_CC_RELIABLE"
1145 if [ -n "$USE_FASTEST_CC" ]
1147 CMK_CC
="$CMK_CC_FASTEST"
1150 if [ -n "$USE_F77" ]
1153 CMK_CF90_FIXED
=$CMK_CF77
1154 CMK_F90LIBS
=$CMK_F77LIBS
1157 if [ -n "$CMK_F90_MODINC" ]
1159 CMK_CF90_MODINC
="$CMK_F90_MODINC"
1161 CMK_CF90_MODINC
="-M"
1164 if [ -n "$F90_MODDIR" ]
1166 for dir
in $F90_MODDIR
1168 OPTS_F90
="$OPTS_F90 $CMK_CF90_MODINC $dir"
1172 if [ -n "$CMK_F90_USE_MODDIR" ]
1174 CMK_CF90
="$CMK_CF90 $CMK_CF90_MODINC $CHARMINC $CMK_SYSINC"
1177 if [ -n "$SEQUENTIAL" ]
1179 CMK_CC
="$CMK_SEQ_CC"
1180 CMK_LD
="$CMK_SEQ_LD"
1181 CMK_CXX
="$CMK_SEQ_CXX"
1182 CMK_CF90
="$CMK_SEQ_F90 "
1183 CMK_LDXX
="$CMK_SEQ_LDXX"
1184 CMK_AR
="$CMK_SEQ_AR"
1185 CMK_RANLIB
="$CMK_SEQ_RANLIB"
1187 CMK_CC_FLAGS
="$CMK_SEQ_CC_FLAGS -DCMK_SEQUENTIAL=1"
1188 CMK_LD_FLAGS
="$CMK_SEQ_LD_FLAGS"
1189 CMK_CXX_FLAGS
="$CMK_SEQ_CXX_FLAGS -DCMK_SEQUENTIAL=1"
1190 CMK_LDXX_FLAGS
="$CMK_SEQ_LDXX_FLAGS"
1195 CMK_CC
="$CMK_NATIVE_CC "
1196 CMK_LD
="$CMK_NATIVE_LD"
1197 CMK_CXX
="$CMK_NATIVE_CXX "
1198 CMK_LDXX
="$CMK_NATIVE_LDXX"
1200 CMK_CC_FLAGS
="$CMK_NATIVE_CC_FLAGS"
1201 CMK_LD_FLAGS
="$CMK_NATIVE_LD_FLAGS"
1202 CMK_CXX_FLAGS
="$CMK_NATIVE_CXX_FLAGS"
1203 CMK_LDXX_FLAGS
="$CMK_NATIVE_LDXX_FLAGS"
1206 if [ -n "$PREPROCESS" ]
1213 CMK_LD
="purify $CMK_LD"
1214 CMK_LDXX
="purify $CMK_LDXX"
1218 if [ "$OPTIMIZE_MODE" = "true" ]
1220 OPTS_CC
="$CMK_C_OPTIMIZE $OPTS_CC"
1221 OPTS_CXX
="$CMK_CXX_OPTIMIZE $OPTS_CXX"
1222 OPTS_F90
="$CMK_F90_OPTIMIZE $OPTS_F90"
1223 OPTS_LD
="$CMK_C_OPTIMIZE $OPTS_LD"
1226 # Pick up per-architecture production mode settings
1227 if [ "$PRODUCTION_MODE" = "true" ]
1229 OPTS_CC
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_CC"
1230 OPTS_CXX
="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_CXX"
1231 OPTS_F90
="$CMK_PRODUCTION $CMK_F90_PRODUCTION $OPTS_F90"
1232 OPTS_LD
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_LD"
1235 if [ -n "$XI_INTERNAL" ]
1237 CMK_XIOPTS
="$CMK_XIOPTS -intrinsic"
1240 if [ "$GENDEPENDS" = "yes" ]
1242 CMK_XIOPTS
="$CMK_XIOPTS -M"
1245 if [ "$COUNTTOKENS" = "yes" ]
1247 CMK_XIOPTS
="$CMK_XIOPTS -count-tokens"
1250 if test "$CMK_WITH_TAU" = "true"
1252 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1253 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1254 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1255 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1256 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1257 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1258 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1263 #Add generic options to the compiler- and linker-options
1264 OPTS_CC
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CC"
1265 OPTS_CXX
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CXX"
1266 OPTS_F90
="$OPTS $OPTS_F90"
1267 OPTS_LD
="$OPTS $OPTS_LD"
1269 # There's really no analog for this in the Bourne shell:
1270 # -------- C Shell ------> onintr failure
1271 # Luckily, it's irrelevant as long as nobody sends us a ^Z.
1273 ##############################################################################
1275 # Check for valid choice of LANGUAGE
1277 ##############################################################################
1278 Debug
"Checking language..."
1280 [ -z "$LANGUAGE" -a -n "$SEQUENTIAL" ] && LANGUAGE
=c
1281 [ -z "$PARADIGM" -a -n "$LANGUAGE" ] && PARADIGM
="$LANGUAGE"
1282 [ -z "$PARADIGM" ] && PARADIGM
="charm++"
1285 "c"|
"C"|
"c++"|
"C++")
1286 [ -z "$SEQUENTIAL" -a -z "$NATIVE" ] && Abort
"Language $LANGUAGE is for sequential programs"
1290 # update charm to bgcharm
1291 [ "$PARADIGM" = "charm++" -a -n "$CMK_BIGSIM" ] && PARADIGM
="bgcharm++"
1292 [ "$PARADIGM" = "converse++" -a -n "$CMK_BIGSIM" ] && PARADIGM
="bgconverse++"
1294 [ "$PARADIGM" = "bgcharm++" ] && TRACEMODE
=`AddList $TRACEMODE bluegene`
1296 if [ $USE_F77_LIBRARIES = "1" ]
1298 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F77LIBS"
1301 if [ $USE_F90_LIBRARIES = "1" ]
1304 if [ ! -r $CHARMLIB/libconv-utilf.a
]
1306 Abort
"Error: Fortran support library $CHARMLIB/libconv-utilf.a missing. Is your Fortran compiler working?"
1309 POST_LIBRARIES
="$POST_LIBRARIES -lconv-utilf $CMK_F90LIBS"
1313 if [ "$CMK_COMPILER" = "bgclang" ]
1315 OPTS_CC_GENCPM
="-x c " # -x c is only applied for the preprocessing of the GEN-CPM files on BG/Q
1318 OPTS_CC_GENCPM
="$OPTS_CC $OPTS_CC_GENCPM"
1320 ############ Determine the language and libraries ##########
1322 # Parse out the real languages
1326 USE_F90_LIBRARIES
="1"
1329 PRE_LIBRARIES
="$PRE_LIBRARIES -lf90charm -lckf"
1330 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F90LIBS"
1332 "bluegene"|
"bigsim")
1333 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs"
1336 POST_LIBRARIES
="$POST_LIBRARIES -lbluegene"
1339 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1342 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1346 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1347 if [ $CMK_CELL -eq 1 ]
1350 if [ "$PARADIGM" = "converse++" ]
1352 # Include a "do nothing" register_accel_spe_funcs() function
1353 POST_LIBRARIES
="$POST_LIBRARIES -lnoAccelStub"
1356 if [ "$PARADIGM" = "charm++" ]
1359 if [ $SPU_USE_CPP -eq 1 ]
1361 SPU_COMPILER
=$CMK_SPU_CXX
1362 SPU_LINKER
=$CMK_SPU_LDXX
1364 SPU_COMPILER
=$CMK_SPU_CC
1365 SPU_LINKER
=$CMK_SPU_LD
1368 # Include the spe object file for linking into main executable
1369 POST_LIBRARIES
="$POST_LIBRARIES main__funcLookup__.genSPECode.ppe.o"
1374 if [ "$AMPIMAIN" != "" ]
1376 OBJECTFILES
="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1379 if [ "$TLSGLOBALS" = "1" ]
1381 if [ "$CMK_GDIR" = "uth" ]
1383 echo "Error: -tlsglobals is not supported with the uth machine layer."
1386 if ! `$CMK_CC --version | grep -q gcc`
1388 echo "Warning: -tlsglobals may not work with compilers other than GCC."
1390 if ! `$CMK_LD -Wl,--version,-v 2>&1 | grep -q elf`
1392 echo "Warning: -tlsglobals may not work with a linker that does not report ELF support."
1396 if [ "$SWAPGLOBALS" = "1" ]
1398 if [ "$CMK_HAS_ELF_H" != "1" ]
1400 echo "Error: -swapglobals requires elf.h"
1404 LD_VERSION_TEXT
=`$CMK_LD -Wl,--version,-v 2>/dev/null`
1405 if ! `printf "$LD_VERSION_TEXT" | grep -q 'GNU ld'`
1407 echo "Warning: -swapglobals may not work with linkers other than GNU ld."
1409 LD_VERSION
=`printf "$LD_VERSION_TEXT" | grep -Eo 'GNU ld (\([^)]*\) )?(version )?[-0-9._a-zA-Z]+' | awk '{print $NF}'`
1410 LD_VERSION_MAJOR
=`printf $LD_VERSION | cut -d. -f1`
1411 LD_VERSION_MINOR
=`printf $LD_VERSION | cut -d. -f2 | cut -d- -f1`
1412 if [ "$LD_VERSION_MAJOR" -gt 2 ] ||
[ "$LD_VERSION_MAJOR" -eq 2 -a "$LD_VERSION_MINOR" -gt 23 ]
1414 echo "Warning: -swapglobals may not work with GNU ld >= 2.24."
1415 echo "For some versions, an experimental patch is available:"
1416 echo 'https://charm.cs.illinois.edu/gerrit/gitweb?p=libbfd-patches.git;a=tree;f=swapglobals'
1420 if [ "$CMK_SMP" = "1" ]
1422 echo "Error: -swapglobals is not supported on SMP builds of Charm++/AMPI"
1425 swapo
="$CHARMLIB/libglobal-swap.a"
1426 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1428 echo "Error: global-swapping library $swapo missing--"
1429 echo " Is -swapglobals supported on this machine?"
1432 MIDDLE_LIBS
="-lglobal-swap $MIDDLE_LIBS"
1436 if [ "$SWAPGLOBALS" = "2" ]
1438 echo "-copyglobals option is no longer supported by Charm++/AMPI"
1444 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1446 POST_LIBRARIES
="-lmpi-mainmodule $POST_LIBRARIES"
1449 ##############################################################################
1451 # Some quick consistency checks in preparation for full link-step
1453 # Check for valid choice of TRACEMODE
1454 # Check for valid choice of BALANCE
1455 # Check for compatibility among BALANCE and TRACEMODE
1457 ##############################################################################
1459 Debug
"About to check TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1461 # Check for valid choice of TRACEMODE
1463 if [ x
"$TRACEMODE" != x
]
1465 for trace
in $TRACEMODE; do
1467 "converse"|
"converse++"|
"bgconverse++"|
"bigsim"|
"bluegene")
1468 if [ "$trace" != "counter" ]; then
1469 Warning
"Tracemode $trace isn't supported in Converse-level programs; Dropping it"
1470 TRACEMODE
=`DropList $trace $TRACEMODE`
1478 TRACE_OBJ
="$TRACE_OBJ -ltrace-$trace"
1483 if test x
$PARADIGM = x
"bgcharm++"
1488 Debug
"Finished with TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1490 BAL_OBJ
="-lldb-$BALANCE -lconv-ldb"
1492 # Check for valid choice of MEMORY
1494 # Set the default expansions of unprefixed variants
1496 'verbose'|
'paranoid'|
'leak'|
'isomalloc')
1500 MEMORY
="gnu-$MEMORY"
1504 # Isomalloc does not work on BGQ or Windows:
1505 if [ "$CMK_BLUEGENEQ" = "1" -o "$CMK_COMPILER" = "msvc" ] && [ "$MEMORY" = "${MEMORY%isomalloc}isomalloc" ]
1507 Abort
"Error: Isomalloc is not supported on BlueGene/Q or Windows."
1510 MEM_OBJ
="-lmemory-${MEMORY}"
1512 # For memory wrapping around the OS allocator, need to add also the wrapper object
1515 MEM_OBJ
=$MEM_OBJ" -lmemory-os-wrapper"
1519 # Check for valid choice of THREAD
1521 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1523 THREAD
=$CMK_LD_SHARED_THREAD
1525 if [ "$TLSGLOBALS" = "1" ]
1527 # make sure we don't add an extra -tls
1528 if ! echo $THREAD |
grep '\-tls$' > /dev
/null
2> /dev
/null
1530 THREAD
=${THREAD}-tls
1534 THREAD_OBJ
="-lthreads-${THREAD}"
1539 modInitName
="moduleinit$$"
1540 modInitSrc
="$modInitName.C"
1541 modInitObj
="$modInitName.o"
1544 ##############################################################################
1546 # Final link step variables
1548 ##############################################################################
1553 CORE_LIBS
="-lconv-core -ltmgr -lconv-util -lconv-partition $TRACE_OBJ $CMK_HWLOC_LIBS"
1555 # get TAU stub makefile variables
1556 if test "$CMK_WITH_TAU" = "true"
1558 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1559 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1560 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1561 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1562 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1563 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1564 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1568 # done getting TAU variables
1570 if [ "$BUILD_SHARE" = "0" ]
1572 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1575 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1580 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1581 if [ -z "$NO_MAIN" ]
1583 MIDDLE_LIBS
="-lckmainf $MIDDLE_LIBS"
1586 if [ "$TAU_TRACE_MPI" = "1" ]
1588 TAU_LIBS
="$TAU_MPI_FLIBS $TAU_LIBS"
1590 TAU_LIBS
="$TAU_LIBS"
1593 "charm"|
"charm++"|
"f90charm"|
"ckbluegene"|
"bgcharm++")
1595 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1596 if [ -z "$NO_MAIN" ]
1600 MIDDLE_LIBS
="-lckmainf $MIDDLE_LIBS"
1602 elif [ -z "$AMPIMAIN" ]
1604 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1607 if [ "$TAU_TRACE_MPI" = "1" ]
1609 TAU_LIBS
="$TAU_MPI_LIBS $TAU_LIBS"
1611 TAU_LIBS
="$TAU_LIBS"
1616 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1618 "converse++"|
"bgconverse++"|
"bluegene"|
"bigsim")
1620 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1622 "c"|
"C"|
"c++"|
"C++"|
"f90"|
"f77")
1625 Abort
"Unrecognized choice of language $LANGUAGE / paradigm $PARADIGM"
1629 if [ "$BUILD_SHARE" = "0" ]
1631 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1634 if [ "$CHARM_SHARED" = "1" ]
1636 [ -z "$CHARMLIBSO" ] && Abort
"Charm++ lib_so directory not found!"
1637 # build user executable/shared lib linking with charm .so
1638 OPTS_LD
="$OPTS_LD $CMK_LD_LIBRARY_PATH"
1639 LANG_LIBS
="-L$CHARMLIBSO"
1641 LANG_LIBS
="-L$CHARMLIB"
1644 if [ -z "$STANDALONE" ]
1646 ALL_LIBS
="$LANG_LIBS $PRE_LIBRARIES $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES"
1648 "charm"|
"charm++"|
"f90charm"|
"ckbluegene"|
"bgcharm++")
1649 ALL_LIBS
="$ALL_LIBS -lmoduleNDMeshStreamer -lmodulecompletion"
1653 ALL_LIBS
="$USER_PRE_LIBRARIES $USER_POST_LIBRARIES"
1656 if [ -n "$LINK_WHOLE_ARCHIVE" ]
1658 ALL_LIBS
="$CXX_NO_AS_NEEDED $LDXX_WHOLE_ARCHIVE_PRE $ALL_LIBS $LDXX_WHOLE_ARCHIVE_POST $CMK_SYSLIBS"
1660 ALL_LIBS
="$ALL_LIBS $CMK_SYSLIBS"
1663 if [ "$BUILD_SHARE" = "0" ]
1665 ALL_LIBS
="$ALL_LIBS $CHARMLIB/conv-static.o"
1668 if [ -n "$LINK_CXX_STL" ]
1670 ALL_LIBS
="$ALL_LIBS -lstdc++"
1673 if [ "$TRACE_WITH_TAU" = 1 ]
1675 echo "Linking with the TAU libraries: $TAU_LIBS"
1676 ALL_LIBS
="$ALL_LIBS $TAU_LIBS"
1678 Debugf
"All libraries are: $ALL_LIBS"
1680 # preserve this variable in its state here for use later
1681 CHARM_ALL_LIBS
="$ALL_LIBS"
1682 if [ "$BUILD_SHARE" = "1" -o -n "$SKIP_MODULEINIT" ]
1684 ALL_LIBS
="$OBJECTFILES $ALL_LIBS"
1686 ALL_LIBS
="$OBJECTFILES $modInitObj $ALL_LIBS"
1689 if [ -n "$F90_MAIN" ]
1691 # for_main needs to be placed at beginning
1692 CMK_LD_FLAGS
="$CMK_F90MAINLIBS $CMK_LD_FLAGS"
1693 CMK_LDXX_FLAGS
="$CMK_F90MAINLIBS $CMK_LDXX_FLAGS"
1696 if [ -n "$F90_MAIN" -o "$USE_F90_LIBRARIES" = '1' ]
1698 if [ "$CMK_CAN_LINK_FORTRAN" != '1' ]
1700 echo "Error: Configure testing was unable to link a Fortran program."
1705 ########################################################################
1707 # Finalize command parameters
1709 ########################################################################
1711 CHARM_CPP_C
="$CMK_CPP_C"
1713 CHARM_CXX
="$CMK_CXX"
1715 CHARM_LDXX
="$CMK_LDXX"
1717 CHARM_CPP_C_FLAGS
="$CMK_CPP_C_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CC_GENCPM $OPTS_CPP"
1718 CHARM_CC_FLAGS
="$CMK_CC_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC"
1719 CHARM_CXX_FLAGS
="$CMK_CXX_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX"
1720 CHARM_LD_FLAGS
="$CMK_LD_FLAGS $CMK_LINK_BINARY $CMK_LIBDIR $OPTS_LD $ALL_LIBS"
1721 CHARM_LDXX_FLAGS
="$CMK_LDXX_FLAGS $CMK_LINK_BINARY $CMK_LIBDIR $OPTS_LD $ALL_LIBS"
1724 ########################################################################
1726 # Print command building blocks and quit, if specified
1728 ########################################################################
1730 if [ -n "$PRINT_BUILDING_BLOCKS" ]
1732 for i
in CHARM_CC CHARM_CXX CHARM_LD CHARM_LDXX CHARM_CC_FLAGS CHARM_CXX_FLAGS CHARM_LD_FLAGS CHARM_LDXX_FLAGS CHARMBIN CHARMINC CHARMLIB CHARMLIBSO
1734 eval "echo $i=\\'\${$i}\\'"
1740 ########################################################################
1742 # We've parsed and verified the command-line parameters.
1743 # Now we prepare routines to clean up and exit.
1744 # None of these routines ever returns-- they all just exit.
1746 ########################################################################
1750 if [ "a$COPYTO" != "a" -a "a$COPYTO" != "a$OBJECT" ]
1752 [ -d $COPYTO ] && COPYTO
="$COPYTO/"
1753 if [ "a$PROG_EXT" != "a" -a -r "$OBJECT$PROG_EXT" ] ; then
1754 Warning
"Appending $PROG_EXT to object file name"
1755 OBJECT
="$OBJECT$PROG_EXT"
1757 [ ! -d $COPYTO ] && DoNoErrCheck
$RM $COPYTO
1758 Do
$CP $OBJECT $COPYTO
1760 test -n "$COPY_EXIT" && Success
1764 for COPY
in `echo $MODCOPIES`
1766 if [ "a$COPY" != "a$OBJECT" ]
1768 [ -d $COPY ] && COPY
="$COPY/"
1769 if [ -n "$CMK_MOD_NAME_ALLCAPS" ] ; then
1770 OBJECT
=`echo $OBJECT | tr "a-z" "A-Z"`
1772 if [ -r "$OBJECT.$CMK_MOD_EXT" ] ; then
1773 Warning
"Appending .$CMK_MOD_EXT to object file name"
1774 OBJECT
="$OBJECT.$CMK_MOD_EXT"
1776 [ ! -d $COPY ] && DoNoErrCheck
$RM $COPY
1777 Do
$CP $OBJECT $COPY
1788 ##############################################################################
1790 # Preprocess the GEN-CPM files
1792 ##############################################################################
1794 Debug
"Preprocessing GEN-CPM files"
1796 for FILE
in `echo $GENCPM`
1798 # This used to be "$FILE:r", which strips the extention
1799 BASE
=`stripExtention $FILE`
1800 MYTMP
=`basename $FILE`".TMP"
1801 DELETE
="$DELETE $MYTMP.c $MYTMP.i"
1802 DoNoErrCheck
$RM $BASE.cpm.h
$MYTMP.c
1803 Do
touch $BASE.cpm.h
1804 Do
$LN -f -s $FILE $MYTMP.c
1805 Do
$CHARM_CPP_C $CHARM_CPP_C_FLAGS $MYTMP.c
> $MYTMP.i
1806 Do
$CHARMBIN/conv-cpm
$MYTMP.i
$BASE.cpm.h
1809 ##############################################################################
1811 # Compile all specified files
1813 # All temporary files named *.TMP.* for easy cleanup.
1815 ##############################################################################
1817 Debug
"About to compile..."
1821 BASE
=`stripExtention \`basename $FILE\
``
1822 MYTMP
=`basename $FILE`".TMP"
1823 FILE_EXT
=`getExtention $FILE`
1827 # in case of: charmc -o object.o -c foo.c,
1828 # avoid foo.c => remove foo.o => foo.o => object.o,
1829 # instead generate object.o directly.
1830 # remove and generate foo.o may be dangerous in parallel make
1831 # for example in the case of compiling several objs from one
1832 # same c file such as memory.C.
1833 if [ $numFiles = 1 -a -n "$OBJECT" ]
1835 OBJ_EXT
=`getExtention $OBJECT`
1836 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1843 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1846 .c|.s|.S|.C|.cc|.cxx|.cpp|.c
++|.cu|.f|.F|.f90|.F90|.fpp|.FPP|.f77|.F77
)
1847 [ $VERBOSE ] && echo "Compiling $FILE"
1848 DoNoErrCheck
$RM $BASEO `stripExtention $BASEO`.f.o
1851 if [ ! -z "$SKIPLINK" ]
1856 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1860 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1863 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++)
1864 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE
1867 *.f|
*.F|
*.f77|
*.F77
)
1868 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1871 *.f90|
*.F90|
*.fpp|
*.FPP
)
1872 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1873 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE
1882 test "$PARADIGM" = "f90charm" && XIOPTS
="$XIOPTS -f90"
1883 if [ "$PREPROCESS_CI" = "yes" ]
1885 Do
$CMK_CPP_CHARM $OPTS_CPP $FILE | Do
$CHARMBIN/charmxi
$XIOPTS -orig-file $FILE
1887 Do
$CHARMBIN/charmxi
$XIOPTS $FILE
1891 Do
$CHARM_CC $CHARM_CC_FLAGS -c $FILE $DESTO
1892 if [ "$Do_res" -ne 0 ]
1897 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu
)
1900 Do
$CMK_NATIVE_CXX $CMK_NATIVE_CXX_FLAGS -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP -c $FILE $DESTO
1902 Do
$CHARM_CXX $CHARM_CXX_FLAGS -c $FILE $DESTO
1904 if [ "$Do_res" -ne 0 ]
1909 *.f|
*.F|
*.f77|
*.F77
)
1910 test -z "$CMK_CF90_FIXED" && Abort
"No F90 compiler (CMK_CF90_FIXED) defined"
1911 Do
$CMK_CF90_FIXED -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE $DESTO
1912 if [ "$Do_res" -ne 0 ]
1917 *.f90|
*.F90|
*.fpp|
*.FPP
)
1918 test -z "$CMK_CF90" && Abort
"No F90 compiler (CMK_CF90) defined"
1919 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1920 Do
$CMK_CF90 -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE $DESTO
1921 if [ "$Do_res" -ne 0 ]
1927 Abort
"I'm not yet smart enough to compile $FILE"
1929 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
1930 [ ! -s $FILE ] && Abort
"$FILE: file not recognized: File truncated"
1938 Abort
"file with unrecognized extension $FILE"
1942 ##############################################################################
1944 # POSSIBLY, SKIP LINK-STEP
1946 # 1. No $OBJECT may be specified at all --- its just a compilation.
1947 # 2. If $OBJECT is a ".a" file, a library is created from $OBJECTFILES.
1948 # 3. If $OBJECT is a ".o" file, then an "LDRO" is created from $OBJECTFILES.
1949 # 4. Language may be sequential. Do a quick and easy linkage.
1951 # in any of these cases, the full link step is skipped.
1953 ##############################################################################
1956 Debugf
"Running ldro..."
1957 DoNoErrCheck
$RM $OBJECT
1958 # convert to absolute path if required
1959 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1961 dir
=`dirname $OBJECT`
1962 fname
=`basename $OBJECT`
1966 if test "$MAKE_LDXX" = "1"
1968 soTool
="$CMK_LDXX $CMK_LDXX_FLAGS"
1970 soTool
="$CMK_LD $CMK_LD_FLAGS"
1972 if [ -n "$STANDALONE" ]
1974 soLibs
="$USER_PRE_LIBRARIES $USER_POST_LIBRARIES"
1976 soLibs
="$PRE_LIBRARIES $POST_LIBRARIES"
1977 [ "$CMK_MACOSX" = "1" ] && OPTS_LD
="$OPTS_LD -Wl,-install_name,$CHARMLIBSO/$fname"
1979 if [ -n "$LINK_WHOLE_ARCHIVE" ]
1981 soLibs
="$CXX_NO_AS_NEEDED $LDXX_WHOLE_ARCHIVE_PRE $soLibs $LDXX_WHOLE_ARCHIVE_POST"
1983 soLibs
="$soLibs $CMK_SYSLIBS"
1984 if [ -n "$LINK_CXX_STL" ]
1986 soLibs
="$soLibs -lstdc++"
1988 soCmd
="$soTool $CMK_LIBDIR -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $soLibs $CMK_LD_SHARED_LIBS"
1991 if [ $Do_res -ne 0 ]
1993 if [ -n "$NOABORT" ]
1997 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1998 echo "!! Failed to compile Charm++ shared library. You can disable shared !!"
1999 echo "!! lib compilation by providing --no-build-shared build option like: !!"
2000 echo "!! ./build charm++ netlrts-linux --no-build-shared -O !!"
2001 echo "!! or reexecute this charmc command with the --no-build-shared option !!"
2002 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
2003 Abort
"Command $soCmd returned error code $Do_res"
2009 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
2011 # We have no target object, or are playing preprocessor tricks-- just end
2012 Debugf
"No target object-- finished"
2016 Debug
"About to link..."
2018 if [ "$INPUT_GIVEN" != "1" ]
2020 Abort
"Trying to link, but no object files or library archives were specified"
2023 # if interoperate dont create the library now, wait to collect all info
2024 if [ "$MPI_INTEROPERATE" = "" ]
2028 Debugf
"Converting $FILES to $OBJECTFILES"
2029 nFiles
=`echo $FILES | wc -w`
2030 nObj
=`echo $OBJECTFILES | wc -w`
2031 # One source file, one .o: just move the .o
2032 if [ $OBJECT != $OBJECTFILES ]
2034 Debugf
"Moving .o to destination"
2035 DoNoErrCheck
$RM $OBJECT
2036 Do
$MV $OBJECTFILES $OBJECT
2040 *.so|
*.so.
*|
*.sl|
*.dylib
)
2041 # Make shared library
2042 # If building shared is not supported and this object is not standalone, exit.
2043 if [ "$BUILD_SHARE" = 0 -a -z "$STANDALONE" ]
2045 Warning
"Warning: building shared library is not supported, recompile charm++ with '--build-shared'."
2047 elif [ "$CHARM_SHARED" = "0" ]
2053 # Make regular (.a, non-shared) library
2054 # in case building charm so, build .so under lib_so as well # Gengbin
2055 if [ "$BUILD_SHARE" = "1" ]
2062 DESTDIR
=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
2063 OBJECT
=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
2065 COPYTO
=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
2068 OBJECT
=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
2069 [ -f $DESTDIR/.charmso
] && MakeSO
2075 DoNoErrCheck
$RM $OBJECT
2076 Do
$CMK_AR $OBJECT $OBJECTFILES
2077 Do
$CMK_RANLIB $OBJECT
2082 # If the above case returns, we're not creating a .o or .a file,
2083 # so linking is needed.
2085 if [ $CMK_CELL -eq 1 ]
2088 if [ "$PARADIGM" = "charm++" ]
2091 # Make the spe object file to be included
2092 Do
$SPU_COMPILER -c -I$CHARMINC $CMK_SYSINC -o main__funcLookup__.genSPECode.o main__funcLookup__.genSPECode.c
-DCMK_CELL_SPE=1
2093 Do
$SPU_LINKER -L$CHARMLIB -o main__funcLookup__.genSPECode main__funcLookup__.genSPECode.o
$CMK_SPERT_LIBS $SPU_EXTRA_LIBS
2094 Do
$CMK_PPU_EMBEDSPU spert_main main__funcLookup__.genSPECode main__funcLookup__.genSPECode.ppe.o
2099 # check if we're linking a sequential object
2101 "c"|
"C"|
"f90"|
"f77")
2104 Do
$CMK_NATIVE_LD $CMK_NATIVE_LD_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2105 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2107 Do
$CMK_SEQ_LD $CMK_SEQ_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2108 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2115 Do
$CMK_NATIVE_LDXX $CMK_NATIVE_LDXX_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2116 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2118 Do
$CMK_SEQ_LDXX $CMK_SEQ_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2119 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2126 ##############################################################################
2128 # Confirm that TRACEMODE, BALANCE, MEMORY, THREAD exist
2130 ##############################################################################
2132 # [ -r $CHARMLIB/libtrace-projections.a ] || Abort "trace libraries not installed. Is Charm++ built properly?"
2134 if [ x
"$TRACEMODE" != x
]
2136 for trace
in $TRACEMODE; do
2137 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort
"charmc : No such tracemode $trace"
2141 BAL_EXT
=`getExtention $BALANCE`
2142 if [ -z "$BAL_EXT" ]; then
2143 # Balance has no extension-- is a library reference
2144 if [ -f "${CHARMLIB}/libldb-$BALANCE.a" ]; then
2145 BAL_OBJ_FILE
="${CHARMLIB}/libldb-$BALANCE.a"
2147 BAL_OBJ_FILE
="${CHARMLIBSO}/libldb-$BALANCE.so"
2150 # Balance has some extension-- must be a .o or .a file
2151 BAL_OBJ_FILE
="$BALANCE"
2154 if [ ! -r "$BAL_OBJ_FILE" ]
2156 if [ "$BALANCE" = "$BAL_OBJ_FILE" ]
2158 Abort
"Could not find load balancer object $BAL_OBJ_FILE"
2160 (cd $CHARMLIB ; ls -al libldb-
*)
2161 Abort
"Unknown load balancer $BALANCE / $BAL_OBJ_FILE"
2165 if [ -f "${CHARMLIB}/libmemory-${MEMORY}.a" ]; then
2166 MEM_OBJ_FILE
="${CHARMLIB}/libmemory-${MEMORY}.a"
2168 MEM_OBJ_FILE
="${CHARMLIBSO}/libmemory-${MEMORY}.so"
2171 if [ ! -r $MEM_OBJ_FILE -o ! -s $MEM_OBJ_FILE ]
2173 (cd $CHARMLIB ; list
=`ls libmemory-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
2174 Abort
"charmc : No such memory mode $MEMORY"
2177 if [ -f "${CHARMLIB}/libthreads-${THREAD}.a" ]; then
2178 THREAD_OBJ_FILE
="${CHARMLIB}/libthreads-${THREAD}.a"
2180 THREAD_OBJ_FILE
="${CHARMLIBSO}/libthreads-${THREAD}.so"
2183 if [ ! -r $THREAD_OBJ_FILE -o ! -s $THREAD_OBJ_FILE ]
2185 (cd $CHARMLIB ; list
=`ls libthreads-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
2186 Abort
"charmc : No such thread mode $THREAD"
2190 ################# Build the module initialization function ##################
2192 if [ -z "$SKIP_MODULEINIT" ]
2194 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
2196 for module
in $MODULES; do
2197 echo "extern void _register$module(void);" >> $modInitSrc
2199 for trace
in $TRACEMODE; do
2200 if test $trace = "summary"
2202 echo " extern void _registerTraceSummary();" >> $modInitSrc
2203 elif test $trace = "projections"
2205 echo " extern void _registerTraceProjections();" >> $modInitSrc
2206 elif test $trace = "simple"
2208 echo " extern void _registerTraceSimple();" >> $modInitSrc
2209 elif test $trace = "Tau"
2211 echo " extern void _registerTraceTau();" >> $modInitSrc
2212 elif test $trace = "utilization"
2214 echo " extern void _registerTraceUtilization();" >> $modInitSrc
2215 elif test $trace = "controlPoints"
2217 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2218 elif test $trace = "perfReport"
2220 Do
$CP $CHARMBIN/fuzzytree.txt fuzzytree.txt
2221 Do
$CP $CHARMBIN/tree.txt tree.txt
2222 echo " extern void _registerTraceAutoPerf();" >> $modInitSrc
2224 elif test $trace = "all"
2226 echo " extern void _registerTraceProjections();" >> $modInitSrc
2227 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2228 echo " extern void _registerTraceSummary();" >> $modInitSrc
2231 if test -n "$BALANCER"
2233 echo "extern void LBDefaultCreate(const char *);" >> $modInitSrc
2235 echo "void _registerExternalModules(char **argv) { (void)argv;" >> $modInitSrc
2236 for module
in $MODULES; do
2237 [ -n "$VERBOSE" ] && echo "Adding registration for module $module"
2238 echo " _register$module();" >> $modInitSrc
2240 for trace
in $TRACEMODE; do
2241 if test $trace = "summary"
2243 echo " _registerTraceSummary();" >> $modInitSrc
2244 elif test $trace = "projections"
2246 echo " _registerTraceProjections();" >> $modInitSrc
2247 elif test $trace = "Tau"
2250 echo " _registerTraceTau();" >> $modInitSrc
2251 elif test $trace = "simple"
2253 echo " _registerTraceSimple();" >> $modInitSrc
2254 elif test $trace = "utilization"
2256 echo " _registerTraceUtilization();" >> $modInitSrc
2257 elif test $trace = "controlPoints"
2259 echo " _registerTraceControlPoints();" >> $modInitSrc
2260 elif test $trace = "perfReport"
2262 echo " _registerTraceAutoPerf();" >> $modInitSrc
2263 elif test $trace = "all"
2265 echo " _registerTraceProjections();" >> $modInitSrc
2266 echo " _registerTraceControlPoints();" >> $modInitSrc
2267 echo " _registerTraceSummary();" >> $modInitSrc
2270 if test -n "$BALANCER"
2272 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
2273 for deflb
in $BALANCER
2275 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
2278 echo "}" >> $modInitSrc
2280 # creating projections
2281 echo "void _createTraces(char **argv) { (void)argv;" >> $modInitSrc
2282 for trace
in $TRACEMODE; do
2283 [ -n "$VERBOSE" ] && echo "Adding registration for trace $trace"
2284 echo "extern void _createTrace$trace(char **argv);" >> $modInitSrc
2285 echo "_createTrace$trace(argv);" >> $modInitSrc
2287 echo "}" >> $modInitSrc
2289 Do
$CHARM_CXX $CHARM_CXX_FLAGS -c $modInitSrc -o $modInitObj
2292 ###############################################################################
2296 ###############################################################################
2298 Debug
"About to perform final link..."
2300 #currently only support creation of .a
2301 if [ "$MPI_INTEROPERATE" != "" ]
2305 # in case building charm so, build .so under lib_so as well # Gengbin
2306 DoNoErrCheck
$RM $OBJECT
2307 if [ -z "$SKIP_MODULEINIT" ]
2309 echo "$CMK_AR $OBJECT $OBJECTFILES $modInitObj"
2310 Do
$CMK_AR $OBJECT $OBJECTFILES $modInitObj
2312 Do
$CMK_RANLIB $OBJECT
2313 echo "export CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\"" > .
/charm_all_libs.sh
2314 echo "CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\""
2317 *.so|
*.so.
*|
*.sl|
*.dylib
)
2318 echo "Warning: building shared library failed; for interoperation build
2325 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2327 # build an application .so linking with charm .so
2328 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
2329 Debugf
"Running ldro..."
2330 DoNoErrCheck
$RM $OBJECT
2331 [ "$MAKE_LDXX" = "1" ] && Do
$CMK_LDXX $CMK_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $ALL_LIBS
2332 [ "$MAKE_LD" = "1" ] && Do
$CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $ALL_LIBS
2335 # Make a regular executable: call the appropriate linker
2336 [ "$MAKE_LDXX" = "1" ] && Do
$CHARM_LDXX $CHARM_LDXX_FLAGS -o $OBJECT
2337 [ "$MAKE_LD" = "1" ] && Do
$CHARM_LD $CHARM_LD_FLAGS -o $OBJECT
2340 ########################################################################
2342 # Copy conv-host to user directory if it is present in installation.
2344 ########################################################################
2346 if test "$COPY_CHARMRUN" = "true"
2348 targ
=charmrun
$CMK_POST_EXE
2349 [ ! -x $CHARMBIN/$targ -a -n "$CMK_POST_EXE" ] && targ
=charmrun
2350 convhost
=conv-host
$CMK_POST_EXE
2352 if [ -x $CHARMBIN/$targ ]
2354 DoNoErrCheck
$RM $targ
2355 DoNoErrCheck
$CP $CHARMBIN/$targ $targ 2> /dev
/null
2359 [ -z "$SKIP_MODULEINIT" -a -z "$SAVE" ] && DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1