Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

dsymutil arguments aren't expanded properly #208

Closed
mstorsjo opened this issue Dec 5, 2016 · 11 comments
Closed

dsymutil arguments aren't expanded properly #208

mstorsjo opened this issue Dec 5, 2016 · 11 comments

Comments

@mstorsjo
Copy link
Contributor

mstorsjo commented Dec 5, 2016

When building with xcbuild, I end up with dsymutil invocations like this:

GenerateDSYMFile /Users/martin/Library/Developer/Xcode/DerivedData/myproj-random/Build/Products/Release-iphoneos/example.app/example
    cd /Users/martin/code/example
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/martin/Library/Developer/Xcode/DerivedData/myproj-random/Build/Products/Release-iphoneos/example.app/example -o 

I.e. the output filename isn't provided at all.

For some reason, when building from xcbuild on OS X, this doesn't actually print any error message or indicate any failure, but when this same command line is called manually, it prints an error like this:

dsymutil: for the -o option: requires a value!

When I try to use xcbuild on linux, the missing parameter to -o ends up being an issue.

@grp
Copy link
Contributor

grp commented Dec 5, 2016

Could you try with #202 applied? I feel like I saw something like this and fixed it but don't remember where; that has a lot of commits and one could maybe help?

@grp
Copy link
Contributor

grp commented Dec 5, 2016

If I didn't, the fix is to add { } around the last parameter to dsymutilResolver->resolve() in FrameworksResolver.cpp. That will treat it as an output path rather than an output directory.

@grp
Copy link
Contributor

grp commented Dec 5, 2016

(Not at a computer today but happy to take a PR if that works.)

@mstorsjo
Copy link
Contributor Author

mstorsjo commented Dec 5, 2016

Thanks for the pointers!

I already tested with the branch from #202, but it didn't help, and neither does adding { } to the last parameter to dsymutilResolver->resolve().

I tried to hunt it down, and the main suspect seems to be around Tool/Environment.cpp and how it populates outputs.

For dsymutil (with a spec file from Xcode 7, probably the same in 8 as well, from PlugIns/Xcode3Core.ideplugin/Contents/Frameworks/DevToolsCore.framework/Resources/BuiltInCompilers.xcspec), it triggers the following if branches in Tool::Environment::Create:

if (tool->outputs()) {
    if (!tool->outputs()->empty()) {
            std::string outputPath = environment.expand(output);
            // outputPath = ""
    }
}

The spec file (both the one in xcode and in xcbuild) has got the following:

Outputs = ( "$(OutputPath)" );

@grp
Copy link
Contributor

grp commented Dec 5, 2016

Interesting, it seems that the issue is that this requires OutputPath to be set to determine the outputs, but xcbuild treats OutputPath as coming from the outputs.

I don't see a clean way to resolve this without a large refactor of all tools, so I'll keep this in mind for when I get to that.

@grp
Copy link
Contributor

grp commented Dec 5, 2016

For now, you could try overriding DEBUG_INFORMATION_FORMAT on the command line to avoid invoking dsymutil at all.

@grp
Copy link
Contributor

grp commented Dec 6, 2016

Wait, the comment above the code you pasted should address this:

/* The tool's outputs may reference the variables from the passed-in outputs. */

If you add the { } as I mentioned, that should set OutputPath to the correct path so the std::string outputPath below is resolved correctly.

@mstorsjo
Copy link
Contributor Author

mstorsjo commented Dec 6, 2016

Adding { } to the resolve() call doesn't seem to change what path it takes in Tool::Environment::Create, and the expanded OutputPath still also is empty. I haven't been able to follow it closely enough to see what's going wrong though.

Adding DEBUG_INFORMATION_FORMAT=dwarf allows avoiding the issue altogether, and likewise does replacing dsymutil with a symlink to /bin/true. (Since I'm trying to use it on linux, I need to fiddle with the toolchain anyway.)

@grp
Copy link
Contributor

grp commented Dec 6, 2016

I wonder if the { } isn't enough — the goal is to use the std::vector<std::string> overload for pbxbuild::Tool::ToolResolver::resolve to provide outputs explicitly. Maybe it needs std::vector<std::string>({ })?

@mstorsjo
Copy link
Contributor Author

mstorsjo commented Dec 6, 2016

Thanks - that does seem to do the trick!

I'll submit a pull request soon. (Github seems to be having some issue with receiving the branch I just pushed.)

mstorsjo added a commit to mstorsjo/xcbuild that referenced this issue Dec 6, 2016
This fixes expanding OutputPath properly for dsymutil, fixing
issue facebookarchive#208.
grp pushed a commit that referenced this issue Dec 7, 2016
This fixes expanding OutputPath properly for dsymutil, fixing
issue #208.
@grp
Copy link
Contributor

grp commented Dec 7, 2016

Yay, glad it worked. Sorry I got that wrong at first — didn't know the rules for how { } is inferred and guessed wrong.

@grp grp closed this as completed Dec 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants