diff --git a/src/cl65/main.c b/src/cl65/main.c index 8b9fe029a..62ce40e2e 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -336,17 +336,19 @@ static void Link (void) { unsigned I; - /* If we have a linker config file given, set the linker config file. - * Otherwise set the target system. + /* If we have a linker config file given, add it to the command line. + * Otherwise pass the target to the linker if we have one. */ if (LinkerConfig) { CmdAddArg (&LD65, "-C"); CmdAddArg (&LD65, LinkerConfig); - } else { + } else if (Target != TGT_NONE) { CmdSetTarget (&LD65, Target); - SetTargetFiles (); } + /* Determine which target libraries are needed */ + SetTargetFiles (); + /* Since linking is always the final step, if we have an output file name * given, set it here. If we don't have an explicit output name given, * try to build one from the name of the first input file.