Avoid the possibility of a zero length generated LD script #323
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See here for some background:
I also experienced this issue when I forgot to add the toolchain to my path and/or used the wrong toolchain
PREFIX
, tried to build an example, and ended up with a zero length.../ch32v003fun/generated_ch32v003.ld
and until this was deleted (or amake clean
performed) then the error persisted:To mitigate/avoid this issue, I suggest making the rule for creating the generated LD script
.PHONY
so that it is always run and thus ensures that the generated linker script is up to date.I tried other approaches but most seem to require more complexity and dependencies on shell features which may not work on all platforms/shells (especially Windows).
Admittedly this is slight abuse of the
.PHONY
feature since this is a file basedMakefile
rule and not something likeclean
,install
etc., and it also means that the LD script will be generated afresh every time a build is done but I believe that the overhead should be minimal and it's arguably a small price to pay to avoid a problem that may confuse users (especially newbies)?What do others think...?
If there is a more elegant alternative approach then I would be interested in hearing about it.
Thanks.