Different behavior when running `make`

Alan Somers asomers at freebsd.org
Fri Dec 8 16:28:21 UTC 2017


On Fri, Dec 8, 2017 at 8:01 AM, Shivansh Rai <shivansh at freebsd.org> wrote:

> Hello all,
>
> I'm currently working on a tool for automating generation of smoketests for
> all the utilities in the base system [1]. Until now I was testing things on
> a very old branch from around August (git sha 92d8705), and after updating
> my branch (git sha 7ea30ed) I'm starting to notice a different behavior.
>
> The tool is located at `~/freebsd/tools/tools/smoketestsuite` [2] in my
> system.
> Executing `make` inside [2] produces the following output -
> ```
> [Creating objdir
> /usr/obj/usr/home/zeebsd/freebsd/amd64.amd64/tools/
> tools/smoketestsuite...]
> c++ -I/usr/local/include -std=c++11 -c logging.cpp
> c++: error: no such file or directory: 'logging.cpp'
> c++: error: no input files
> *** Error code 1
> ```
>
> The interesting thing to be noted is the first line of the above trace
> where a new directory under `/usr/obj` is created (I've noticed this for
> the first time, after I updated my branch).
>
> The location
> `/usr/obj/usr/home/zeebsd/freebsd/amd64.amd64/tools/tools/smoketestsuite`
> [3] is empty, and it seems that `make` tries to look up `logging.cpp` (and
> all other files) in [3] instead of [2]. This is evident from the fact that
> if I manually populate [3] will all the relevant files, everything works
> fine.
> Also, all the side-effects which `make` introduces (new files, new binaries
> etc.) are populated at [3] instead of [2].
>
> If the tool is kept at a location outside the src tree (not under
> `~/freebsd`), everything works fine (and the temporary directory under
> `/usr/obj` is not created for those locations when `make` is executed). So
> the problem seems to be in the way `make` is running inside the src tree.
>
> I've attached the system call trace for the failing execution.
> It'd be extremely helpful if someone could please shed light on what seems
> to be the problem here, and what should be the right workflow.
>
> [1]: For some more reference, the tool is currently available at `
> https://github.com/shivansh/smoketestsuite/' (svn branch) (D12249).
> [2]: `~/freebsd/tools/tools/smoketestsuite`
> [3]:
> `/usr/obj/usr/home/zeebsd/freebsd/amd64.amd64/tools/tools/smoketestsuite`
>
> Thanks in advance!
> With best regards,
> Shivansh Rai
>

make is failing because it's implicitly cd'ing to
${MAKEOBJDIRPREFIX}/${.CURDIR} before running any commands.  I don't know
if that's at all contingent on the build being started from within a
FreeBSD source tree, but the easiest solution is to work with the build
system rather than against it.  I've attached a working version.  The
scripts don't all work, however.  They still contain assumptions about pwd,
for example at scripts/fetch_utils.sh:32.

-Alan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 673 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20171208/fe25478b/attachment.obj>


More information about the freebsd-hackers mailing list