Unnecessary recompilation? #208

Closed
opened 2022-12-21 15:18:18 +02:00 by cultab · 3 comments

This threw me off a bit, is this the expected behavior?

Behavior

  1. $ make compiles the project.
  2. $ make install attempts to install and obviously fails if $PREFIX is default.
  3. # make install attempts to recompile and install.

Expected behavior

  1. $ make compiles the project.
  2. $ make install attempts to install and obviously fails if $PREFIX is default.
  3. # make install uses binary from step 1 and install it.
This threw me off a bit, is this the expected behavior? # Behavior 1. `$ make` compiles the project. 1. `$ make install` attempts to install and obviously fails if `$PREFIX` is default. 1. `# make install` attempts to recompile and install. # Expected behavior 1. `$ make` compiles the project. 1. `$ make install` attempts to install and obviously fails if `$PREFIX` is default. 1. `# make install` uses binary from step 1 and install it.

I wasn't able to replicate this. I did

  • make
  • make install as non-root, failed because of default $PREFIX
  • make PREFIX=/tmp/ install worked without recompiling
I wasn't able to replicate this. I did - `make` - `make install` as non-root, failed because of default `$PREFIX` - `make PREFIX=/tmp/ install` worked without recompiling

The problem appers when running make install with root permitions e.g.
sudo make install .
With changing the PREFIX it works if the folder is user writeable.

The problem appers when running `make install` with root permitions e.g. `sudo make install` . With changing the PREFIX it works if the folder is user writeable.

Ah. Most probably you don't have the same cargo environment variables as the user and as root. So when you run with sudo, cargo rebuilds it because cargo home (usually $HOME/.cargo) is different. So it's expected behavior, because of the way cargo works and how the makefile target is defined. I think if the target was defined as the binary filename instead of a PHONY named target it wouldn't recompile it because Make would see it already exists.

Reference for cargo rebuild behavior: https://github.com/rust-lang/cargo/issues/10499

Ah. Most probably you don't have the same cargo environment variables as the user and as root. So when you run with sudo, cargo rebuilds it because cargo home (usually $HOME/.cargo) is different. So it's expected behavior, because of the way cargo works and how the makefile target is defined. I think if the target was defined as the binary filename instead of a PHONY named target it wouldn't recompile it because Make would see it already exists. Reference for cargo rebuild behavior: https://github.com/rust-lang/cargo/issues/10499
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: meli/meli#208
There is no content yet.