Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Dec 2011 16:09:24 GMT
From:      "Tim &#268;as" <darkuranium@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/163567: Make forgets to chdir back to the original directory after finding an object dir
Message-ID:  <201112231609.pBNG9OPd015949@red.freebsd.org>
Resent-Message-ID: <201112231610.pBNGAA8w005567@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         163567
>Category:       bin
>Synopsis:       Make forgets to chdir back to the original directory after finding an object dir
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 23 16:10:10 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Tim &#268;as
>Release:        9.0 RC3
>Organization:
n/a
>Environment:
FreeBSD tsibsd.tsi 9.0-RC3 FreeBSD 9.0-RC3 #0: Sun Dec  4 08:56:36 UTC 2011     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
If the "make" utility finds an object dir, it changes to the path of the dir, but forgets to change back to the working directory.

A consequence of this is that portable makefiles do not work with BSD's implementation simply because there exists an "obj" directory in the tree.

This means that, say, trying to compile src/main.c actually invokes the compiler on (non-existing) obj/src/main.c.
>How-To-Repeat:
Run the following in a shell ('$' indicates a prompt):

$ rm -rf obj
$ echo -e "all:\n\tpwd" > Makefile
$ make
pwd
/path/to/dir
$ mkdir obj
$ make
pwd
/path/to/dir/obj

The effect is the same if "pwd" is replaced with \$\$PWD (which generates "$$PWD" instead of "pwd" in the makefile.
>Fix:
The problem is that chdir_verify_path does not change the directory back on success.

In the file /usr/src/usr.bin/make/main.c, change the function chdir_verify_path() - right before "return (obpath)", add:

chdir(curdir);

(plus checks to see if this went fine).


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112231609.pBNG9OPd015949>