-
Notifications
You must be signed in to change notification settings - Fork 521
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
Fix iverilog files not update bug during overwrite installation #300
Conversation
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.84, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.84, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.84, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
I think prefixing is enough to fix the problem. the only case, where it will not work, would be a tar-based source installation in linux from scratch. By the way, to fix the race-condition with the install directory, I would you order-only-prerequisite types like
--> have a look here: |
prefixing targets with Consider this timestamp sequence: User at time t3 (t3 > t2) installs release A, but then found out release A+1 is out too, so it It's true that if the user runs I don't think prefixing Of course, one way to solve the specific problem I mentioned with prefixing The takeaway is that: the |
as I stated before a lot of makefiles that i have seen will break in the scenario you mentioned. you'll use a package manager (or how would you be able to remove orphaned files?), or use a repository.
|
DESTDIR is only used for packaging, I agree. But with your proposed change,
regular `make install` without DESTDIR will still exhibit incorrect
behavior for the cases I showed.
(Showing that there exists other incorrectly written Makefiles doesn't mean
we have to join them, especially if there is a correct way to handle those
cases.)
The only correct way is to *unconditionally* overwrite all destination
files while installing.
There is no easy way to remove orphaned files, and the only reliable way to
remove them is to run `make uninstall` from the *original* version.
Hopefully the newly installed files should overwrite all existing files.
The installdirs fix could use order-only prerequisites, but I believe for
this specific case, the difference doesn't matter in practice.
(How could my change force rebuild all targets when directory timestamp is
changed? It will only force reinstallation of the files when you run `make
install` again, but that is *exactly* what you want when you do `make
install`.)
|
Again, for a pedantic and 100% correct solution Let's have a look at "real world" examples:
both will fail at the current state and work with $(DESTDIR). |
The size of the PR seems large is only because each file is split into
each own commit.
Either of your proposed .PHONY or $(DESTDIR)-prefixing solutions will
still change all 20 Makefiles, so with the one-file-per-commit
organization, it will also result in 20 commits.
Thus your point of simpler solution (in terms of commit count) doesn't hold.
Also, your list of real-world examples conveniently omit one of the
more common usage scenarios where prefixing $(DESTDIR) fails.
3. the user regularly downloads source tarball and manually installs
(updates) into /usr/local/.
If we have to fix the problem, let's fix it completely this time, not partially.
And for 3, the problem with $(DESTDIR)-prefixing fix will lead to very
subtle problems for the user (some of the headers file are silently
not updated.)
The .PHONY solution is ok in this regard, but the only benefit it
offers is that it enables parallel installation of multiple targets,
and it's slightly simpler.
The reason I don't like .PHONY is that it's completely negates the
benefit of providing the dependency information to make, and it's a
unconventional usage of .PHONY, which is supposedly used to label
targets that are not actually files/directories (like clean, install
and installdirs). If make doesn't need the dependency for each
installed file, then just don't provide it and list all installed
files of the same kind under the recipe for each kind.
The current PR is larger but is modeled after automake generated
Makefiles, and it represents a generally accepted approach to this
problem.
The other reason against .PHONY is that, we will need to include a
comment explaining why we provide .POHNY for a file that actually
exists, and it adds more cognitive load to future maintainers,
otherwise, the maintainer might forget to add a new install file to
.PHONY and reintroduce this problem. That's why I think .PHONY
solution, while correct, is actually more error prone that the
proposed approach. (Just imagine if you want to add to add a new
installed file: The .PHONY solution requires you to add one more rule
and also one more .PHONY declaration, but with this change, you just
change the dependency of the appropriate rule and add one more line to
its recipe. Which one is easier and less error prone? Not only is the
2nd one simpler, it also has less opportunity for errors.)
|
To summarize:
If it's for a local patch in Gentoo portage, .PHONY solution would be the
best, as it minimizes diff size and we can afford to include comments
explaining this reason why .PHONY is needed.
But for the upstream, we need a solution that is not only 100% correct but
also with the least cognitive load and least error-prone for future changes.
|
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.84, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.84, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
Thanks for the detailed explanation, I also consider that if not fixed, even when compiling with git source code, assuming a distributed scenario of shared file system, this problem still exists. So the installation process must be performed exactly, rather than checking the timestamp. order-only-prerequisite is nice to resolve parallel installation dependency problem, the current code is solved using another way. e.g.: install: obj_b
@echo C
obj_b: obj_a
@echo B
obj_a:
@echo A The order is A, and then B, C In this parallel install fix, |
…10.3 and 9999 The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.84, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.85, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.85, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
The upstream's Makefile used a very unusual installation method. It may cause overwrite installation bug. A fix pull request have been send to upstream steveicarus/iverilog#300 This ebuild fix will update all files' timestamp before compile. This have tested on my overlay: https://github.com/vowstar/vowstar-overlay Closes: https://bugs.gentoo.org/705412 Package-Manager: Portage-2.3.85, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
I think this is one for Steve to decide. |
I think the original premise of this issue may be mistaken. In particular, the install rule was standard practice for a very long time. The only obvious issue, though, is the absence of $(DESTDIR) in the target rule. I can see that being fixed. (DESTDIR is only used when installing to a fake root, or something similar.) I haven't looked at the commits yet, but that's my brief thinking. |
As mentioned earlier, prefixing $(DESTDIR) will only fix the case when
$(DESTDIR) is specified and $(DESTDIR) points to an empty tree.
And it will break for the regular "make; make install" scenario (when
updating an previous installation).
(see #300 (comment)
for
an example.)
When installing, we must not consider the timestamp of the target files and
must overwrite them unconditionally.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve in the sense that I'm not opposed to these changes. The make files as they are have always worked fine for me, even when making packages, but if this change makes the makefiles more robust, then OK then. So long as the changes don't add a lot of complexity.
Can everyone on this conversation review and approve the sum total of the changes? I reviewed the changes, and to my eye, they seem OK. There has been some debate, I know, but this issue hasn't impacted me. To review, go the "Files Changed" tab at the top of this pull request. The green "Review Changes" button would be a great place to submit the review, and explicitly approve the pull request. Thanks, all. |
Thank you! I tried approve but found that the submitter was unable to approve their own code. |
Testing this with an out-of-tree build gives the following failure:
|
It is very weird, It build success in my environment. I list the
Which branch or package are you using? |
I build a clean environment using docker whith The FROM debian:bullseye
LABEL maintainer="vowstar"
# Update and install base software
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq \
build-essential \
autoconf \
gperf \
bison \
flex \
wget \
curl \
git \
python \
perl \
sudo
# Fetch
RUN mkdir /build && \
cd /build && \
git clone --progress --recursive https://github.com/vowstar/iverilog.git && \
git clone --progress --recursive https://github.com/steveicarus/ivtest.git && \
cd /build/iverilog && \
git checkout fix-makefile
# Build
RUN cd /build/iverilog && \
sh autoconf.sh && \
./configure && \
make && \
make install
# Test
RUN cd /build/ivtest && \
perl ./vvp_reg.pl
Build with command: The build and test log is: https://pastebin.com/5kxKkn1w The line 2035 (https://pastebin.com/5kxKkn1w) shows that
|
Apart from Debian and Gentoo, there is no problem building on CentOS8. The CentOS8 build log (build success): The docker file: FROM centos:8
LABEL maintainer="vowstar"
# Update and install base software
RUN dnf -y update && \
dnf -y groupinstall 'Development Tools' && \
dnf -y --enablerepo=PowerTools install \
autoconf \
gperf \
bison \
flex \
wget \
curl \
git \
python36 \
perl \
sudo
# Fetch
RUN mkdir /build && \
cd /build && \
git clone --progress --recursive https://github.com/vowstar/iverilog.git && \
git clone --progress --recursive https://github.com/steveicarus/ivtest.git && \
cd /build/iverilog && \
git checkout fix-makefile
# Build
RUN cd /build/iverilog && \
sh autoconf.sh && \
./configure && \
make && \
make install
# Test
RUN cd /build/ivtest && \
perl ./vvp_reg.pl
|
You need to try an out-of-tree build. Try this:
|
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
fix install timestamp check and Remove useless $(INSTALL_DOC) Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
fix install timestamp check and Remove useless $(INSTALL_DOC) Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
fix install timestamp check and Remove useless $(INSTALL_DOC) Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
fix install timestamp check and Remove useless $(INSTALL_DOC) Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
fix install timestamp check and Remove useless $(INSTALL32) Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix tgt-fpga/Makefile.in vvp/Makefile.in doc Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
Fix bug: https://bugs.gentoo.org/705412 Fix bug: gentoo/gentoo#14096 Related: steveicarus#294 Signed-off-by: Huang Rui <vowstar@gmail.com>
When installing tgt-stub and tgt-vhdl, due to the wrong target path, the install scripts can't find the file to be installed. The missing file is: stub.conf, stub-s.conf, vhdl.conf, vhdl-s.conf Changed to right path fixed this problem. Thanks @minux help to fix. Signed-off-by: Huang Rui <vowstar@gmail.com>
In PR steveicarus#300, @xdch47 pointed out a stable way to fix parallel installation problems. This fix applied the method, thanks! Signed-off-by: Huang Rui <vowstar@gmail.com>
eb1865d
to
11001f5
Compare
@martinwhitaker Thank you for detailed explanation , I already understand what happened. I rebased the code to latest and changed to right path fixed this problem: 969426a This problem may also be reproduced on other branches. Thanks @minux and @xdch47 for helping fix these issues, I applied your solution in these commits. Dockerfile for testing an out-of-tree build: FROM debian:bullseye
LABEL maintainer="vowstar"
# Update and install base software
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq \
build-essential \
autoconf \
gperf \
bison \
flex \
wget \
curl \
git \
python \
perl \
sudo
# Fetch
RUN mkdir /workspace && \
cd /workspace && \
git clone --progress --recursive https://github.com/vowstar/iverilog.git && \
git clone --progress --recursive https://github.com/steveicarus/ivtest.git && \
cd /workspace/iverilog && \
git checkout fix-makefile
# Build
RUN cd /workspace/iverilog && \
sh autoconf.sh && \
mkdir /workspace/build && \
cd /workspace/build && \
../iverilog/configure && \
make -j && \
make -j install
# Test
RUN cd /workspace/ivtest && \
perl ./vvp_reg.pl
Test result: Build and install success, the test log is:
|
Do we have any update? |
Sorry, new day job.
Merged this pull request.
…On Sat, Feb 29, 2020 at 12:54 AM Rui Huang ***@***.***> wrote:
Do we have any update?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#300?email_source=notifications&email_token=AAACKMREBGYDDUM52ETGEPLRFDGKXA5CNFSM4KIR6QG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENLUIRY#issuecomment-592921671>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACKMUYGZYTVKKSN7OTIMDRFDGKXANCNFSM4KIR6QGQ>
.
--
Steve Williams "The woods are lovely, dark and deep.
steve@icarus.com <steveicarus@gmail.com> But I have promises
to keep,
http://www.icarus.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."
|
Removed unused patch because it merged into upstream steveicarus/iverilog#300 Package-Manager: Portage-2.3.89, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com>
Removed unused patch because it merged into upstream steveicarus/iverilog#300 Package-Manager: Portage-2.3.89, Repoman-2.3.20 Signed-off-by: Huang Rui <vowstar@gmail.com> Closes: #14809 Signed-off-by: Joonas Niilola <juippis@gentoo.org>
The most original detailed information is here: https://bugs.gentoo.org/705412
Detailed Description:
The original Makefile used a very unusual installation method, e.g.,
https://github.com/steveicarus/iverilog/blob/master/Makefile.in#L356
It checks$(includedir)/vpi_user.h but installed to "$ (DESTDIR)$(includedir)/vpi_user.h"
If an old version of iverilog is already installed, when download a new released compressed package and decompress it, the timestamp of source code may old and when doing overwrite installation, the old file may not update due to the installed file have new timestamp.
This causes some problems, which can happen in the following cases:
I'm thinking about how to fix it, firstly I've tried update the timestamp of all source
find . -exec touch {} +
It success but too dirty, I don't want recompile every time and it may cause other problem.
Also I'm thinking about change code like this:
But it only fix the problem on gentoo Linux, In general the problem exist.
I also think about how to install by checksum files, but Makefile can't beautifully do it.
Add
.PHONY
toinstall
also too weird.So, I don't use the above method.
In order to install correctly every time, the installation (
INSTALL_DATA/INSTALL_PROGRAM/INSTALL_SCRIPT
) should not just check the results based on timestamp, Instead, perform a true overwrite installation to ensure that the program behaves correctly.Even if I install the new version first and then overwrite installation the old version of the iverilog, It is unreasonable not to install it due to timestamp is old.
I changed 20
Makefile.in
files and use traditional method to doINSTALL_DATA/INSTALL_PROGRAM/INSTALL_SCRIPT
, by the way fix some hidden parallel compilation problem, improve the maintainability of the installation script to make it look simpler.