Author Topic: "Target is up to date" is wrong  (Read 5342 times)

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
"Target is up to date" is wrong
« on: November 09, 2011, 10:02:59 am »
I configured C::B to work with an embedded toolchain for a 16-bit microcontroller. After many tests, I reached a working configuration but for a thing.

In the Project/target options/Build targets window, I set ABS/myproject.abs in the Output filename field and I uncheck both Auto-generate ... checkboxes. In this way, C::B knows the executable is in ABS subfolder of the project folder.

The command line for the linker (configured in Settings/Compiler and debugger/Other settings/Advanced options) is:
$linker -f "$(PROJECT_DIR)\OPT\$(PROJECT_NAME).opl" $link_options -Xcwno

In the OPT\myproject.opl file there are the options for the linker from the original IDE that I want to continue using. One of the option in this file is the classical output filename:
  -o ABS\myproject.abs
as before.

If I modify a single source file and click on Build button, the compilation of the changed file and the linking are well done and I correctly found the executable in ABS subfolder.
If I modify a single source file and click on Build file button, the compilation of the changed file is well done and I found the updated object file. After that, if I click on Build, C::B outputs the message: Target is up to date. It's not true, because the ABS\myproject.abs is older than the object file of the changed source (that is created with Build file).

At the moment I solved adding a pre-build step:
CMD /C IF EXIST ABS\$(PROJECT_NAME).abs DEL ABS\$(PROJECT_NAME).abs
In this way, the executable is always deleted before building, so the linking is always executed, even if the target is really up to date.

When does C::B decide that the target is up to date? Only if the file exists? Do it compare the date of the target file and the date of all the object files?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: "Target is up to date" is wrong
« Reply #1 on: November 09, 2011, 10:57:16 am »
When does C::B decide that the target is up to date? Only if the file exists? Do it compare the date of the target file and the date of all the object files?
It's a date/time comparison of all the files that require to be compiled / linked in, including external dependency files (setup at project/target level).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: "Target is up to date" is wrong
« Reply #2 on: November 09, 2011, 04:07:49 pm »
Quote
It's a date/time comparison of all the files that require to be compiled / linked in, including external dependency files (setup at project/target level).
I make the following steps:
1. Rebuild the project with success
Now all the object files and the target file are updated. I don't have any external dependency file.
2. Edit a single source file
3. Build only the edited file
Now the object of the edited file is surely newer than the target file.
4. Build the entire project -> "Target is up to date"

What could be the reason?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: "Target is up to date" is wrong
« Reply #3 on: November 09, 2011, 04:32:37 pm »
3. Build only the edited file
Now the object of the edited file is surely newer than the target file.
4. Build the entire project -> "Target is up to date"
This step is invalid.

The source file's time stamp is compared to the executables time stamp. Interim files are not being progressed for good reasons, one is that they could have any file name.

so you should always build the project instead of a single file only. This results in the same thing: C::B will only compile the files modified.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: "Target is up to date" is wrong
« Reply #4 on: November 10, 2011, 12:00:39 am »
3. Build only the edited file
Now the object of the edited file is surely newer than the target file.
4. Build the entire project -> "Target is up to date"
This step is invalid.

The source file's time stamp is compared to the executables time stamp. Interim files are not being progressed for good reasons, one is that they could have any file name.
Yes, of course. At step 4 (build the entire project), C::B should note that the edited source file is newer than target file and trigger a linking process.

I tried with the standard configuration of GCC compiler and it works as expected. If I modify a single source file, build only this file and after build the project, I see the linking process takes place.
So it's my custom configuration that doesn't work, but I don't know why!