From 953961ca903335d3a5f19ebc240ba73228d6481f Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 4 Sep 2020 22:01:06 -0500 Subject: [PATCH] Bugfix: featureless make should not attempt to link to non-existent library. 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 | 2 +- level_3/fake/c/private-build.c | 19 +++++++++++-------- level_3/fake/data/build/settings-example-bzip2 | 5 ++--- level_3/fake/data/build/settings-example-bzip2recover | 5 ++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/build/scripts/bootstrap.sh b/build/scripts/bootstrap.sh index 613b266..6341a17 100644 --- a/build/scripts/bootstrap.sh +++ b/build/scripts/bootstrap.sh @@ -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 diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 67b518d..fe720f0 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -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; diff --git a/level_3/fake/data/build/settings-example-bzip2 b/level_3/fake/data/build/settings-example-bzip2 index d11ca78..a4e6f4d 100644 --- a/level_3/fake/data/build/settings-example-bzip2 +++ b/level_3/fake/data/build/settings-example-bzip2 @@ -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 diff --git a/level_3/fake/data/build/settings-example-bzip2recover b/level_3/fake/data/build/settings-example-bzip2recover index 95e831e..5004eb2 100644 --- a/level_3/fake/data/build/settings-example-bzip2recover +++ b/level_3/fake/data/build/settings-example-bzip2recover @@ -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 -- 1.8.3.1