Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6287] utils/build-script can't handle spaces in path to Xcode #48837

Closed
davedelong opened this issue Nov 2, 2017 · 9 comments
Closed

[SR-6287] utils/build-script can't handle spaces in path to Xcode #48837

davedelong opened this issue Nov 2, 2017 · 9 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers

Comments

@davedelong
Copy link

Previous ID SR-6287
Radar None
Original Reporter @davedelong
Type Bug
Status Closed
Resolution Cannot Reproduce
Environment

macOS 10.13

Xcode 9.1 GM (9B55)

Additional Detail from JIRA
Votes 0
Component/s Project Infrastructure
Labels Bug, StarterBug
Assignee None
Priority Medium

md5: 88d670da60efa0246ef98d7f7ab61099

Issue Description:

I have spaces in my path to Xcode (/Applications/Xcode 9.1 GM.app).

When I attempt to build Swift using utils/build-script, it silently dies with a cryptic message of:

usage: dirname path
./utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

  1. This is a bad error message and

  2. I should be able to have spaces in my path to Xcode

@phausler
Copy link
Member

phausler commented Nov 3, 2017

SR-3353 duplicate it looks...

@davedelong
Copy link
Author

Certainly related to SR-3353. That one is about spaces in the path to the swift clone, and this one is about spaces in the path to Xcode.

@phausler
Copy link
Member

phausler commented Nov 3, 2017

Yea I guess not a dup per se but likely the same type of logical flaw

@modocache
Copy link
Mannequin

modocache mannequin commented Nov 3, 2017

Since this has a very clear way to reproduce the issue, I'm going to label this as a "StarterBug". I think a good series of steps to begin working on this would be to:

  1. Confirm that you can build Swift by using utils/build-script.

  2. Rename your copy of Xcode so that it contains spaces in its name.

  3. Try re-building Swift from scratch (you may want to remove your old build directory, in case it has cached any of the build settings, such as the old Xcode path). If you encounter errors, look into swift/utils/build-script, swift/utils/build-script-impl, swift/CMakeLists.txt, etc.

I'd be happy to help anyone who chooses to work on this, I think I can help answer most questions about the Swift build system. 🙂

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 7, 2017

Comment by Tassilo von Gerlach (JIRA)

Just stated reading your blog posts @modocache and will give this a shot.

@swift-ci
Copy link
Collaborator

Comment by Tassilo von Gerlach (JIRA)

I've spent some time trying to solve the issue, but I'm going in circles at this point and was hoping for any insights or pointers in the right direction. I was able to fix the initial crash by changing

HOST_CXX_DIR=$(dirname ${HOST_CXX})

to

HOST_CXX_DIR=$(dirname "${HOST_CXX}")

in utils/build-script-impl line 2666. By wrapping HOST_CXX in quotes it treats it as a single argument as opposed to multiple ones separated by the space in the Xcode path.

However, after applying this fix the build now fails with this message.

[13/2689] Linking CXX static library lib/libLLVMDemangle.a
FAILED: lib/libLLVMDemangle.a
: && /Applications/Xcode With Spaces.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -no_warning_for_no_symbols -o lib/libLLVMDemangle.a lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o && :
/bin/sh: /Applications/Xcode: No such file or directory
[20/2689] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/CachePruning.cpp.o
ninja: build stopped: subcommand failed.
../swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

I have tried to do the following things:

  1. There are a few places where the Xcode path is hardcoded. I've adjusted them to match my current Xcode path, but that hasn't changed anything.

  2. I have looked for other places where variables aren't wrapped in double quotes and I've wrapped a lot of them, with no luck. There are a lot so it's definitely possible that I haven't found the right location, but I have been unable to track down the precise spot where such a failure might occur. Any tips on how to find such a location would be great.

  3. I have also looked at the call function in build-script-impl, but have had trouble understanding what the function does. Since I'm pretty inexperienced I'm not sure if relevant, but it is the last place I've been able to add print statements to before the build fails.

Any insights would be greatly appreciated. Thanks.

@belkadan
Copy link
Contributor

Resetting assignee on all Starter Bugs not modified since 2018.

@belkadan
Copy link
Contributor

(sorry, tvongerlach (JIRA User))

@swift-ci
Copy link
Collaborator

Comment by Valeriy Van (JIRA)

`./utils/build-script` builds normally with Xcode having spaces in its name provided `xcode-select` properly set path.

I.g. I've set path with:

`sudo xcode-select -s /Applications/Xcode\ 11.5.app/Contents/Developer`.

Then build process ran with `./swift/utils/build-script --clean --xcode --release-debuginfo --debug-swift` completed successfully.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants