Project

General

Profile

Actions

Bug #11949

closed

make -C caches wrong directory contents

Added by Andy Fiddaman over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

make -C does a chdir() call to the target directory but this is currently done too late, after the contents of the working directory (.) is cached, and after any local make.rules file is read.

Here's a basic example, from the root of the illumos-gate checkout:

% /usr/bin/make -C usr/src/tools/env
make: Fatal error: No arguments to build
Current working directory /data/omnios-build/omniosorg/bloody/illumos/usr/src/tools/env

% touch Makefile illumos.sh

% /usr/bin/make -C usr/src/tools/env
/usr/bin/rm -f illumos
cat illumos.sh > illumos
chmod +x illumos

I wrote a set of tests to check the behaviour of -C both on the command line and in MAKEFLAGS, along with assorted makefiles and make.rules files and they almost all fail:

FAIL make -C a/ from empty directory
PASS make -C a/ from non-empty directory
FAIL makeflags -C a/ from empty directory
PASS makeflags -C a/ from non-empty directory
FAIL make -C a/a from empty directory
FAIL make -C a/a from non-empty directory
FAIL makeflags -C a/a from empty directory
FAIL makeflags -C a/a from non-empty directory
FAIL make -C a/b from empty directory
FAIL make -C a/b from non-empty directory
FAIL makeflags -C a/b from empty directory
FAIL makeflags -C a/b from non-empty directory
FAIL make -C a/c from empty directory
FAIL make -C a/c from non-empty directory
FAIL makeflags -C a/c from empty directory
FAIL makeflags -C a/c from non-empty directory
FAIL make -C -C from empty directory
FAIL make -C -C from non-empty directory
FAIL makeflags -C -C from empty directory
FAIL makeflags -C -C from non-empty directory
FAIL make -C -C relative from empty directory

Related issues

Related to illumos gate - Feature #10891: dmake could support -CClosedRobert Mustacchi

Actions
Actions #1

Updated by Andy Fiddaman over 1 year ago

Review posted at https://illumos.org/rb/r/2447/diff/1/#

Test results with that change:

PASS make -C a/ from empty directory
PASS make -C a/ from non-empty directory
PASS makeflags -C a/ from empty directory
PASS makeflags -C a/ from non-empty directory
PASS make -C a/a from empty directory
PASS make -C a/a from non-empty directory
PASS makeflags -C a/a from empty directory
PASS makeflags -C a/a from non-empty directory
PASS make -C a/b from empty directory
PASS make -C a/b from non-empty directory
PASS makeflags -C a/b from empty directory
PASS makeflags -C a/b from non-empty directory
PASS make -C a/c from empty directory
PASS make -C a/c from non-empty directory
PASS makeflags -C a/c from empty directory
PASS makeflags -C a/c from non-empty directory
PASS make -C -C from empty directory
PASS make -C -C from non-empty directory
PASS makeflags -C -C from empty directory
PASS makeflags -C -C from non-empty directory
PASS make -C -C relative from empty directory
PASS make -C error
PASS make -C error (output)
PASS MAKEFLAGS=-C error
PASS MAKEFLAGS=-C error (output)
PASS make -C <noexist>
PASS make -C <noexist> (output)
PASS MAKEFLAGS=-C <noexist>
PASS MAKEFLAGS=-C <noexist> (output)
Actions #2

Updated by Andy Fiddaman over 1 year ago

Actions #3

Updated by Electric Monk over 1 year ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit ae389aa988ce154c9f8d5d4dbe4a63c3744339f4

commit  ae389aa988ce154c9f8d5d4dbe4a63c3744339f4
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2019-11-15T14:11:06.000Z

    11949 make -C caches wrong directory contents
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF