bkaradzic / GENie

GENie - Project generator tool
Other
905 stars 168 forks source link

[ninja] ar: difference between GNU ar (Linux) and BSD ar (BSD, macOS) #498

Closed KageKirin closed 4 years ago

KageKirin commented 4 years ago

Hi there,

I hope you're doing fine. I stumbled over this annoying issue with responsefiles when using ninja with XCode's ar.

The error is the following:

[6/6] ar -rcs ../../bin/darwin/libflatbuffers.a @../../bin/darwin/libflatbuffers.a.rsp  2>&1 > /dev/null | sed -e '/.o) has no symbols$/d'
ar: @../../bin/darwin/libflatbuffers.a.rsp: No such file or directory

coming from this ninja rule:

rule ar
  command         = ar $flags $out @$out.rsp  2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'

changing the line to remove the responsefile fixes it.

rule ar
  command         = ar $flags $out $in $libs  2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'

So the reason for this appears to be a subtle difference between GNU ar and BSD ar:
GNU ar takes response files with the @, eg. @libar.a.rsp, while BSD ar does not support response files.

I guess, I'll prepare a fix for this...

Cheers.

bkaradzic commented 4 years ago

What happens when command line is really long?

Yeah PR would be good.

KageKirin commented 4 years ago

What happens when command line is really long?

You'll have to use GNU ar in that case.

I quickly verified, but the manual (man ar) does not mention responsefiles, so yes, this needs fixing. I'll create the PR shortly.

bkaradzic commented 4 years ago

cc @rhoot

KageKirin commented 4 years ago

500 is the fix.

I know this changes default behavior, but it makes the behaviour similar to the gmake generator.

Alternatively, I could also rename the flags UseObjectResponseFile and UseLDResponseFile to NoObjectResponseFile and NoLDResponseFile respectively, and inverse the logic in ninja_cpp.lua and make_cpp.lua.

rhoot commented 4 years ago

I like it this way, having to opt-in to potentially unsupported behavior rather than opt out. Merged.

What happens when command line is really long?

You're screwed, hah. But no more screwed than you were before.