Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Possibly mssing target dependencies in Makefile #479

Closed
NexAdn opened this issue Dec 15, 2022 · 4 comments · Fixed by #481
Closed

[BUG] Possibly mssing target dependencies in Makefile #479

NexAdn opened this issue Dec 15, 2022 · 4 comments · Fixed by #481
Assignees
Labels
bug Something isn't working

Comments

@NexAdn
Copy link
Contributor

NexAdn commented Dec 15, 2022

Describe the bug

In Gentoo Bug 884005 we noticed builds failing due to files not being created with e.g. this output from the Tinderbox:

Assembler messages:
Fatal error: can't create obj/btop_menu.o: No such file or directory
Assembler messages:
Fatal error: can't create obj/btop_draw.o: No such file or directory

As described by a user on the gentoo-user mailing list, the problem might be that the mkdir commands for the output directories didn't finish before some jobs attempted to open files in said directories, leading to write failures.

To Reproduce

The aforementioned user got this problem by building on a machine with many jobs in parallel (here it was -j17).

Expected behavior

The compiler should be able to open the files for writing.

Screenshots

Screenshots not applicable, but you might be interested in some of this output:

Info (please complete the following information):

  • btop++ version: btop -v – Not applicable, since the build failed. As can be deduced from the build log, a build of 1.2.13 was attempted.
  • Binary: self compiled
  • (If compiled) Compiler and version: From the build log: CXX ?| x86_64-pc-linux-gnu-g++ (12.2.1)
  • Architecture: [x86_64, aarch64, etc.] uname -m: amd64
  • Platform: Gentoo Linux
  • (Linux) Kernel: uname -r: Linux-6.0.10-x86_64-AMD_Ryzen_9_5950X_16-Core_Processor-with-glibc2.36
  • (OSX/FreeBSD) Os release version: Not applicable
  • Terminal used: Not applicable
  • Font used: Not applicable

Additional context

contents of ~/.config/btop/btop.log – Not applicable

GDB Backtrace

Not applicable.

@NexAdn NexAdn added the bug Something isn't working label Dec 15, 2022
@NexAdn
Copy link
Contributor Author

NexAdn commented Dec 15, 2022

As we already discussed in the Gentoo bug, the issue is probably that the build targets don't depend on the directories target, thus allowing make to execute both targets in parallel, which breaks the build on the rare occasion that mkdir takes longer than g++ takes to make the open() call.

@NexAdn
Copy link
Contributor Author

NexAdn commented Dec 15, 2022

Of course depending on the directories target is not possible for this build system as the dependencies are used as input to the g++ command lines, thus forbidding a dependency on phony targets.

An alternative solution might be calling mkdir -p in the build jobs.
This is an idempotent way of creating the output directories and should be multi-job safe.
Or one could rewrite the all target to call $(MAKE) instead of using the dependcy mechanism:

all:
    $(MAKE) directories
    $(MAKE) btop

@Flowdalic
Copy link

I think this is a prime use case for an order-only prerequisite.

@NexAdn
Copy link
Contributor Author

NexAdn commented Dec 15, 2022

Didn't even know that existed, but StackOverflow helped 😅

I'll open a PR.

NexAdn added a commit to NexAdn/btop that referenced this issue Dec 15, 2022
Since directory creation is a requirement for writing the built
artifacts, this commit introduces a dependency on the directories for
all build targets (compile and link), so parallel builds can't fail
because a build target is executed before the directories target.

Closes: aristocratos#479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants