From: Kevin Day Date: Fri, 9 Jan 2015 00:34:06 +0000 (-0600) Subject: Bugfix: revert compiler workaround 5bdaa0b, place arguments after source X-Git-Tag: 0.4.2~12 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=ebec215a325ccd7926c6a393959bc35ec1c2c258;p=fll Bugfix: revert compiler workaround 5bdaa0b, place arguments after source The problem turns out to be that, for gcc at the very least, linker options such as -lc are not properly passed to the linker when it is before the source files. Using the examples: 1) gcc -lc main.c 2) gcc main.c -lc In case of #1, the -lc is not passed to the linker. In case of #2, the -lc is passed to the linker. All arguments are now being moved after the source parts. see: 5bdaa0b Workaround: compilers on some systems seem to be sensitive to the order of arguments see: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html --- diff --git a/build/scripts/generate.sh b/build/scripts/generate.sh index 719ef49..7ae9afb 100644 --- a/build/scripts/generate.sh +++ b/build/scripts/generate.sh @@ -121,16 +121,6 @@ generate_main(){ generate_operation_build fi - elif [[ $operation == "build_alt" ]] ; then - if [[ -f ${path_build}.built$project_built ]] ; then - echo -e "${c_warning}WARNING: this project has already been built.$c_reset" - else - if [[ ! -f ${path_build}.prepared$project_built ]] ; then - generate_prepare_build alt - fi - - generate_operation_build alt - fi elif [[ $operation == "clean" ]] ; then generate_operation_clean elif [[ $operation == "fail-multiple" ]] ; then @@ -170,7 +160,6 @@ generate_help(){ echo echo -e "$c_highlight$system_name$c_reset $c_notice<${c_reset}operation$c_notice>$c_reset" echo -e " ${c_important}build${c_reset} Build or compile the code" - echo -e " ${c_important}build_alt${c_reset} Build or compile the code (workaround for certain systems)" echo -e " ${c_important}clean${c_reset} Delete all build files" echo echo -e "${c_highlight}Options:$c_reset" @@ -287,7 +276,6 @@ generate_operation_build(){ local sources_headers=${variables[$(generate_id build_sources_headers)]} local sources_settings=${variables[$(generate_id build_sources_settings)]} local sources= - local sources_alt= local i= local alt=$1 @@ -306,19 +294,12 @@ generate_operation_build(){ if [[ $failure == "" && $shared == "yes" ]] ; then if [[ $sources_library != "" ]] ; then sources= - sources_alt= - if [[ $alt == "alt" ]] ; then - for i in $sources_library ; do - sources_alt="$sources_alt$path_c$i " - done - else - for i in $sources_library ; do - sources="$sources$path_c$i " - done - fi + for i in $sources_library ; do + sources="$sources$path_c$i " + done - echo $compiler $sources_alt $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/lib$name.so.$major.$minor.$micro - $compiler $sources_alt $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/lib$name.so.$major.$minor.$micro || failure=1 + echo $compiler $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/lib$name.so.$major.$minor.$micro $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} + $compiler $sources -shared -Wl,-soname,lib$name.so.$major -o ${path_build}libraries/lib$name.so.$major.$minor.$micro $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_library)]} || failure=1 if [[ $failure == "" ]] ; then ln -vsf lib$name.so.$major.$minor.$micro ${path_build}libraries/lib$name.so.$major || failure=1 @@ -328,61 +309,33 @@ generate_operation_build(){ if [[ $failure == "" && $sources_program != "" ]] ; then sources= - sources_alt= - if [[ $alt == "alt" ]] ; then - if [[ $sources_library != "" ]] ; then - for i in $sources_library ; do - sources_alt="$sources_alt$path_c$i " - done - fi - - for i in $sources_program ; do - sources_alt="$sources_alt$path_c$i " - done - else - if [[ $sources_library != "" ]] ; then - for i in $sources_library ; do - sources="$sources$path_c$i " - done - fi - - for i in $sources_program ; do + if [[ $sources_library != "" ]] ; then + for i in $sources_library ; do sources="$sources$path_c$i " done fi - echo $compiler $sources_alt $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} $sources -o ${path_build}programs/$name - $compiler $sources_alt $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} $sources -o ${path_build}programs/$name || failure=1 + for i in $sources_program ; do + sources="$sources$path_c$i " + done + + echo $compiler $sources -o ${path_build}programs/$name $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} + $compiler $sources -o ${path_build}programs/$name $arguments ${variables[$(generate_id flags_shared)]} ${variables[$(generate_id flags_program)]} || failure=1 fi elif [[ $failure == "" ]] ; then sources= - sources_alt= if [[ $sources_library != "" ]] ; then - if [[ $alt == "alt" ]] ; then - for i in $sources_library ; do - sources="$sources${path_build}libraries/$i.o " - sources_alt="$sources_alt$sources " - - echo $compiler $path_c$i $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} -c -static -o ${path_build}libraries/$i.o - $compiler $path_c$i $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} -c -static -o ${path_build}libraries/$i.o || failure=1 - - if [[ $failure == "1" ]] ; then - break; - fi - done - else - for i in $sources_library ; do - sources="$sources${path_build}libraries/$i.o " - sources_alt="$sources_alt$sources " + for i in $sources_library ; do + sources="$sources${path_build}libraries/$i.o " + sources_alt="$sources_alt$sources " - echo $compiler $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} $path_c$i -c -static -o ${path_build}libraries/$i.o - $compiler $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} $path_c$i -c -static -o ${path_build}libraries/$i.o || failure=1 + echo $compiler $path_c$i -c -static -o ${path_build}libraries/$i.o $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} + $compiler $path_c$i -c -static -o ${path_build}libraries/$i.o $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_library)]} || failure=1 - if [[ $failure == "1" ]] ; then - break; - fi - done - fi + if [[ $failure == "1" ]] ; then + break; + fi + done if [[ $failure == "" ]] ; then echo $linker rcs ${path_build}libraries/lib$name.a $sources_alt @@ -415,8 +368,8 @@ generate_operation_build(){ done fi - echo $compiler $sources_alt $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} $sources -static -o ${path_build}programs/$name - $compiler $sources_alt $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} $sources -static -o ${path_build}programs/$name || failure=1 + echo $compiler $sources -static -o ${path_build}programs/$name $sources_alt $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} + $compiler $sources -static -o ${path_build}programs/$name $sources_alt $arguments ${variables[$(generate_id flags_static)]} ${variables[$(generate_id flags_program)]} || failure=1 fi fi