swiftlang / swift-llbuild

A low-level build system, used by Xcode and the Swift Package Manager
Apache License 2.0
1.09k stars 199 forks source link

[SR-3374] swift build fails due to path name #795

Open swift-ci opened 7 years ago

swift-ci commented 7 years ago
Previous ID SR-3374
Radar None
Original Reporter --marc (JIRA User)
Type Bug
Environment macOS 10.11.6 terminal shell: /bin/zsh Apple Swift version 3.0.2 (swiftlang-800.0.61 clang-800.0.42.1) Target: x86_64-apple-macosx10.9 Apple Swift Package Manager - Swift 3.0.2 (swiftpm-11750)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | llbuild | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 182b030cfd483551acc4eff9abb03d93

Issue Description:

swift build fails due to path name. Discovered when following the Swift Getting Started Using the Package Manager.

Example parent folder name which causes swift build fail: 4`2/`6=Test Case

TEST CASE

Uses /bin/zsh shell

# create parent folder which will cause a build fail
export UNICODE1=`echo '\x60'`
cd ~/Desktop
mkdir 4${UNICODE1}2:${UNICODE1}6=Test\ Case
cd 4\`2:\`6=Test\ Case/
# follow Getting Started steps 
mkdir Hello
cd Hello
swift package init
swift build

RESULTING ERROR

Compile Swift Module 'Hello' (1 sources)
<unknown>:0: error: error reading dependency file: '/Users/me/Desktop/4`2:`6=Test Case/Hello/.build/debug/Hello.build/Hello.d' (missing ':' following rule)
<unknown>:0: error: error reading dependency file: '/Users/me/Desktop/4`2:`6=Test Case/Hello/.build/debug/Hello.build/Hello.d' (missing ':' following rule)
<unknown>:0: error: error reading dependency file: '/Users/me/Desktop/4`2:`6=Test Case/Hello/.build/debug/Hello.build/Hello.d' (missing ':' following rule)
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/me/Desktop/4`2:`6=Test\ Case/Hello/.build/debug.yaml
aciidgh commented 7 years ago

hah fun, this might be an issue in llbuild, need to investigate

aciidgh commented 7 years ago

if there is a directory named = swift creates a dependency file:

/private/tmp/Hello/=/.build/debug/_.build/main.swift.o : /private/tmp/Hello/=/Sources/main.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule
/private/tmp/Hello/=/.build/debug/_.build/main~partial.swiftmodule : /private/tmp/Hello/=/Sources/main.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule
/private/tmp/Hello/=/.build/debug/_.build/main~partial.swiftdoc : /private/tmp/Hello/=/Sources/main.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule

But the llbuild makedeps parser considers = invalid word char:
https://github.com/apple/swift-llbuild/blob/master/lib/Core/MakefileDepsParser.cpp#L34

@ddunbar suggestions?

ddunbar commented 7 years ago

This may not be solvable without changing the compiler, I don't know if the makefile can actually represent this (IIRC, there are some "unrepresentable" characters).

The right thing to do here is move to a "real" format for communicating dependencies between the compiler and the build system.