tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: cwrapper trouble with bup on macOS



Tobias Nygren <tnn%NetBSD.org@localhost> writes:

> On Mon, 16 Jun 2025 08:06:37 -0400
> Greg Troxel <gdt%lexort.com@localhost> wrote:
>
>>   $ CWRAPPERS_CONFIG_DIR=work/.cwrapper/config /opt/pkg/libexec/cwrappers/cc-wrapper 
>>   clang: error: no input files
>> 
>>   $ CWRAPPERS_CONFIG_DIR=work/.cwrapper/config /opt/pkg/libexec/cwrappers/cpp-wrapper
>>   exec failed
> 
> Not all versions of Darwin have /usr/bin/cpp and it can depend on
> command line tools, so pkgsrc is usually configured to use the C
> compiler in preprocessor mode.
>
> In pkgsrc infra, CPP on Darwin is defined to "clang -E -" if unset.
> But the bootstrap installs an override in mk.conf which sets CPP to
> "$ {CC} -E" (without the trailing -) when using clang.
> I'm sure there is a good reason for doing it this way.

My mk.conf (not sure when it was bootstrapped indeed had
  CPP=                   ${CC} -E

> Anyway; this is what is causing the problem. The C compiler expects an
> expicit input file. If you change bup's build to call it's discovered
> preprocessor with "-" as input when pipeline mode is requested it will
> probably work on all systems.

That sounds like a plausible bug, but I have figured out that my problem
is different.  (Your explanation was hugely helpful in leading me down a
useful debugging path; thanks very much for taking the time to write.)

Even after changing to CPP=cpp (my system has it in /usr/bin), and
rebuilding cwrappers, I still got "exec failed".  This is not
"preprocesor errored out due to no file given", but something worse.

Reading the wrapper config file, I see

  exec=clang -E

After hand editing that to

  exec=cpp

it builds.   It almost feels like wrappers are calling exec on "clang
-E" (and yes Taylor, I know I should learn dtrace!).  But actually there
is even a space after -E, and then I created a file "clang -E " (yes
with two spaces) in ~/bin, and it got executed with args

  -pipe configure-1P2sCG/ngc41317.c -I/opt/pkgsrc/sysutils/bup/work/.buildlink/include


So the problem is the wrapper executing the string with a space as if it
were a pathname.

Questions arising:

  Is it a bug in cwrappers that exec= doesn't parse spaces and use first
  word as command and rest as first args?

  Is it a bug for cwrappers to use clang -E despite mk.conf having cpp?

  Why is nobody else having problems?  Is the intersection of packages
  needing cpp and people building on macOS really that small?

  How does "clang -E " end up in cwrappers config files?


Home | Main Index | Thread Index | Old Index