]> Kevux Git Server - fll/commitdiff
Bugfix: featureless make should not attempt to link to non-existent library.
authorKevin Day <thekevinday@gmail.com>
Sat, 5 Sep 2020 03:01:06 +0000 (22:01 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 5 Sep 2020 03:01:06 +0000 (22:01 -0500)
When the no library sources are specified then the library is not built.
The problem is that the code is still trying to link against this library that was not built when compiling the static program.

build/scripts/bootstrap.sh
level_3/fake/c/private-build.c
level_3/fake/data/build/settings-example-bzip2
level_3/fake/data/build/settings-example-bzip2recover

index 613b266..6341a17 100644 (file)
@@ -893,7 +893,7 @@ bootstrap_operation_build() {
         fi
       done
 
-      if [[ $failure == "" ]] ; then
+      if [[ $failure == "" && $sources_library != "" ]] ; then
         if [[ $verbosity == "verbose" ]] ; then
           echo $linker rcs ${path_build}libraries/static/lib$name.a $sources
         fi
index 67b518d..fe720f0 100644 (file)
@@ -2458,17 +2458,20 @@ extern "C" {
 
       source_library_length = 0;
 
-      memcpy(source_library, data.path_build_libraries_static.string, data.path_build_libraries_static.used);
-      source_library_length += data.path_build_libraries_static.used;
+      // only include the library if there are sources that would result in it being built.
+      if (data_build.setting.build_sources_library.used) {
+        memcpy(source_library, data.path_build_libraries_static.string, data.path_build_libraries_static.used);
+        source_library_length += data.path_build_libraries_static.used;
 
-      memcpy(source_library + source_library_length, fake_build_parameter_library_name_prefix, fake_build_parameter_library_name_prefix_length);
-      source_library_length += fake_build_parameter_library_name_prefix_length;
+        memcpy(source_library + source_library_length, fake_build_parameter_library_name_prefix, fake_build_parameter_library_name_prefix_length);
+        source_library_length += fake_build_parameter_library_name_prefix_length;
 
-      memcpy(source_library + source_library_length, data_build.setting.project_name.string, data_build.setting.project_name.used);
-      source_library_length += data_build.setting.project_name.used;
+        memcpy(source_library + source_library_length, data_build.setting.project_name.string, data_build.setting.project_name.used);
+        source_library_length += data_build.setting.project_name.used;
 
-      memcpy(source_library + source_library_length, fake_build_parameter_library_name_suffix_static, fake_build_parameter_library_name_suffix_static_length);
-      source_library_length += fake_build_parameter_library_name_suffix_static_length;
+        memcpy(source_library + source_library_length, fake_build_parameter_library_name_suffix_static, fake_build_parameter_library_name_suffix_static_length);
+        source_library_length += fake_build_parameter_library_name_suffix_static_length;
+      }
 
       source_library[source_library_length] = 0;
 
index d11ca78..a4e6f4d 100644 (file)
@@ -3,7 +3,6 @@
 # @fixme: this reveals some shortcomings and problems:
 # 1) need to be able to build -m bzip2recover without libbzip2.a.
 # 2) need to provide a way to designate path prefixes (instead of just hardcoded sources/c/, etc...
-# 3) need to be able to build shared program without library (add a 'build_library' setting).
 
 project_name bzip2
 
@@ -24,8 +23,8 @@ build_compiler gcc
 build_language c
 build_linker ar
 build_libraries -lc
-build_sources_library blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c
-build_sources_program bzip2.c
+build_sources_library
+build_sources_program blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c bzip2.c
 build_sources_headers bzlib.h
 build_sources_script
 build_sources_setting
index 95e831e..5004eb2 100644 (file)
@@ -3,7 +3,6 @@
 # @fixme: this reveals some shortcomings and problems:
 # 1) need to be able to build -m bzip2recover without libbzip2.a.
 # 2) need to provide a way to designate path prefixes (instead of just hardcoded sources/c/, etc...
-# 3) need to be able to build shared program without library (add a 'build_library' setting).
 
 project_name bzip2recover
 
@@ -17,8 +16,8 @@ environment
 process_pre
 process_post
 
-modes 
-modes_default 
+modes
+modes_default
 
 build_compiler gcc
 build_language c