Bug 445211 - [PATCH] fix out of tree builds
Summary: [PATCH] fix out of tree builds
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 309783 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-11-09 15:00 UTC by Alexander Kanavin
Modified: 2022-12-23 16:04 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
patch to fix out of tree builds (7.38 KB, patch)
2021-11-09 15:00 UTC, Alexander Kanavin
Details
v2 with requested adjustments (8.51 KB, patch)
2021-11-12 09:38 UTC, Alexander Kanavin
Details
v3 with requested adjustments (9.69 KB, patch)
2021-11-24 09:47 UTC, Alexander Kanavin
Details
v4 with doc fix (10.23 KB, patch)
2022-04-04 09:20 UTC, Alexander Kanavin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kanavin 2021-11-09 15:00:31 UTC
Created attachment 143375 [details]
patch to fix out of tree builds

Yocto project has been carrying this patch for a while; I believe this allows building valgrind in a separate build directory:
Comment 1 Paul Floyd 2021-11-12 08:48:47 UTC
This looks OK but the patch needs updating for the FreeBSD suppressions.
Comment 2 Alexander Kanavin 2021-11-12 09:38:01 UTC
Created attachment 143477 [details]
v2 with requested adjustments
Comment 3 Paul Floyd 2021-11-22 09:02:05 UTC
I'll try to test the patch this week and then get back to you.
Comment 4 Paul Floyd 2021-11-23 21:35:02 UTC
This fails for mpi (with a 'build' directory in the Valgrind srcdir)

In file included from ../../mpi/libmpiwrap.c:99:
../../mpi/../memcheck/memcheck.h:72:10: fatal error: 'valgrind.h' file not found
#include "valgrind.h"
         ^~~~~~~~~~~~
1 error generated.
gmake[2]: *** [Makefile:747: libmpiwrap_amd64_freebsd_so-libmpiwrap.o] Error 1
gmake[2]: Leaving directory '/usr/home/paulf/scratch/valgrind/build/mpi'
gmake[1]: *** [Makefile:897: all-recursive] Error 1
gmake[1]: Leaving directory '/usr/home/paulf/scratch/valgrind/build'
gmake: *** [Makefile:760: all] Error 2

It might work by accident if I had the Valgrind package installed.

The problem seems to be that valgrind.h is generated from a .in file, so is in ../include relative to build/mpi

Perhaps 

mpi/Makefile.am:libmpiwrap_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = -I$(top_srcdir)/include

should be -I $(top_builddir) ?
Comment 5 Alexander Kanavin 2021-11-24 09:47:46 UTC
Created attachment 143897 [details]
v3 with requested adjustments

Thanks, adjusted patch attached.
Comment 6 Paul Floyd 2022-04-04 07:15:30 UTC
Sorry for the long delay.

"gmake" now seems OK in the out of tree directory, but if I run

"gmake check" then I get

gmake[3]: Entering directory '/usr/home/paulf/scratch/valgrind/build/docs'
gmake[3]: *** No rule to make target '../../docs/xml/vg-entities.xml', needed by 'valid-manual'.  Stop.
gmake[3]: Leaving directory '/usr/home/paulf/scratch/valgrind/build/docs'
gmake[2]: *** [Makefile:555: check-am] Error 2
gmake[2]: Leaving directory '/usr/home/paulf/scratch/valgrind/build/docs'
gmake[1]: *** [Makefile:897: check-recursive] Error 1
gmake[1]: Leaving directory '/usr/home/paulf/scratch/valgrind/build'
gmake: *** [Makefile:1196: check] Error 2
Comment 7 Alexander Kanavin 2022-04-04 09:20:34 UTC
Created attachment 147953 [details]
v4 with doc fix

This is now corrected too :)
Comment 8 Paul Floyd 2022-04-07 19:49:37 UTC
I still have problems with the docs directory. I'll see if Mark W has time to take a look.
Comment 9 Alexander Kanavin 2022-04-07 19:57:27 UTC
I believe you need to re-run autogen.sh. Somehow automake didn't re-do the makefiles with this change for me :-/
Comment 10 Mark Wielaard 2022-04-07 20:59:03 UTC
The supp and mpi changes look correct. Thanks.
I also got an issue with the generated vg-entities.xml.
But this was solved by running autoreconf -f instead of ./autogen.sh which I don't fully understand.
Comment 11 Mark Wielaard 2022-04-07 21:04:16 UTC
(In reply to Mark Wielaard from comment #10)
> I also got an issue with the generated vg-entities.xml.
> But this was solved by running autoreconf -f instead of ./autogen.sh which I
> don't fully understand.

Nope, that was just me being silly and then doing a srcdir == builddir build
The issue occurs during xmllint checking from make check:

Making check in docs
make[2]: Entering directory '/tmp/valgrind-obj/docs'
make  check-local
make[3]: Entering directory '/tmp/valgrind-obj/docs'
if type xmllint 2>/dev/null; then \
  xmllint --noblanks --noout --xinclude --postvalid --noent ../../valgrind/docs/xml/index.xml && \
  touch valid-manual; \
fi
xmllint is /usr/bin/xmllint
../../valgrind/docs/xml/index.xml:4: warning: failed to load external entity "../../valgrind/docs/xml/vg-entities.xml"
[ <!ENTITY % vg-entities SYSTEM "vg-entities.xml"> %vg-entities; ]>
                                                                ^
../../valgrind/docs/xml/index.xml:11: parser error : Entity 'rel-type' not defined
    <releaseinfo>&rel-type; &rel-version; &rel-date;</releaseinfo>
Comment 12 Mark Wielaard 2022-04-07 21:36:33 UTC
So we were missing a few more search path, but the following seems to make document generation work again with srcdir != builddir

--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -124,11 +124,12 @@ LOGFILE = print.log
 
 # validation stuff
 XMLLINT       = xmllint
-XMLLINT_FLAGS = --noblanks --noout --xinclude --postvalid --noent
+XMLLINT_FLAGS = --noblanks --noout --xinclude --postvalid --noent \
+               --path $(top_builddir)/docs/xml
 
 # stylesheet processor
 XSLTPROC       = xsltproc
-XSLTPROC_FLAGS = --nonet --xinclude
+XSLTPROC_FLAGS = --nonet --xinclude --path $(top_builddir)/docs/xml
 
 # stylesheets
 XSL_HTML_CHUNK_STYLE  = $(mylibdir)/vg-html-chunk.xsl
@@ -238,7 +239,8 @@ print-docs:
        cp $(myimgdir)/*.png $(myprintdir)/images && \
        xmlto -v $(WITH_FOP) --stringparam=keep.relative.image.uris="1" \
              -x $(XSL_FO_STYLE) \
-             --searchpath print pdf $(myxmldir)/index.xml &> $(LOGFILE) && \
+             --searchpath $(top_builddir)/docs/xml:print \
+             pdf $(myxmldir)/index.xml &> $(LOGFILE) && \
        echo "Generating PS file: $(myprintdir)/index.ps ..." && \
        pdftops index.pdf && \
        mv index.pdf index.ps $(myprintdir) && \
@@ -353,7 +355,8 @@ download-docs:
        cp $(myimgdir)/*.png $(vgdir)/print/images/
        xmlto -v $(WITH_FOP) --stringparam=keep.relative.image.uris="1" \
              -x $(XSL_FO_STYLE) \
-             --searchpath print pdf $(myxmldir)/index.xml &> $(LOGFILE)
+             --searchpath $(top_builddir)/docs/xml:print \
+             pdf $(myxmldir)/index.xml &> $(LOGFILE)
        mv index.pdf $(vgdir)/print/manual.pdf
        @echo ""
        @echo "Generating valgrind_manual.ps.bz2 ..."
Comment 13 Mark Wielaard 2022-04-07 21:53:41 UTC
Thanks, it works fine now with the new search paths. Pushed as:

commit 2c0fb665699309e1e02a02084324748f46a6c788
Author: Randy MacLeod <Randy.MacLeod@windriver.com>
Date:   Tue Oct 16 21:01:04 2018 -0400

    Fix out of tree builds.
    
    The paths to these files need to be fully specified in
    the out of tree build case. glibc-2.X.supp is a generated file so the
    full path is deliberately not specified in that case.
    
    Also adjust the mpi include dir location as valgrind.h is
    generated as well and needs to be taken out of build dir.
    
    Also adjust the location of generated xml file. And the search paths
    for the xmllint, xsltproc and xmlto programs.
    
    Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Comment 14 Paul Floyd 2022-04-08 11:14:07 UTC
Checked on FreeBSD, gmake and gmake check now both work out of tree.
Comment 15 Paul Floyd 2022-06-07 15:51:59 UTC
Been fixed for a while.
Comment 16 Paul Floyd 2022-12-23 16:04:47 UTC
*** Bug 309783 has been marked as a duplicate of this bug. ***