swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.04k stars 10.32k forks source link

[SR-6240] Missing dependency between include/swift/Syntax/SyntaxKind.h and everything else #48791

Open jckarter opened 6 years ago

jckarter commented 6 years ago
Previous ID SR-6240
Radar None
Original Reporter @jckarter
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 31043061a7a901681bc39307465d705d

Issue Description:

In a clean build, parts of the system that rely on Syntax's generated headers can lose the race against the headers getting generated:

FAILED: lib/ClangImporter/CMakeFiles/swiftClangImporter.dir/ClangImporter.cpp.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++   -DCMARK_STATIC_DEFINE -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/ClangImporter -I/Users/jgroff/src/s/swift/lib/ClangImporter -Iinclude -I/Users/jgroff/src/s/swift/include -I/Users/jgroff/src/s/llvm/include -I/Users/jgroff/src/s/build/Ninja-DebugAssert/llvm-macosx-x86_64/include -I/Users/jgroff/src/s/build/Ninja-DebugAssert/llvm-macosx-x86_64/tools/clang/include -I/Users/jgroff/src/s/llvm/tools/clang/include -I/Users/jgroff/src/s/cmark/src -I/Users/jgroff/src/s/build/Ninja-DebugAssert/cmark-macosx-x86_64/src -Wno-unknown-warning-option -Werror=unguarded-availability-new -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fcolor-diagnostics -Werror=switch -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk    -fno-exceptions -fno-rtti -target x86_64-apple-macosx10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -arch x86_64 -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/../../../Developer/Library/Frameworks -mmacosx-version-min=10.9 -O0 -g -UNDEBUG -MD -MT lib/ClangImporter/CMakeFiles/swiftClangImporter.dir/ClangImporter.cpp.o -MF lib/ClangImporter/CMakeFiles/swiftClangImporter.dir/ClangImporter.cpp.o.d -o lib/ClangImporter/CMakeFiles/swiftClangImporter.dir/ClangImporter.cpp.o -c /Users/jgroff/src/s/swift/lib/ClangImporter/ClangImporter.cpp
In file included from /Users/jgroff/src/s/swift/lib/ClangImporter/ClangImporter.cpp:35:
In file included from /Users/jgroff/src/s/swift/include/swift/Parse/Lexer.h:26:
In file included from /Users/jgroff/src/s/swift/include/swift/Syntax/SyntaxParsingContext.h:16:
In file included from /Users/jgroff/src/s/swift/include/swift/Syntax/RawTokenSyntax.h:25:
/Users/jgroff/src/s/swift/include/swift/Syntax/RawSyntax.h:33:10: fatal error: 'swift/Syntax/SyntaxKind.h' file not found
#include "swift/Syntax/SyntaxKind.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

This can be worked around by explicitly doing ninja swift/Syntax/SyntaxKind.h then resuming the rest of the build, but there ought to be a dependency here.

jckarter commented 6 years ago

Paging @harlanhaskins

harlanhaskins commented 6 years ago

Targets that depend on these headers should declare a dependency on swift-syntax-generated-headers, but this gets hairy when dealing with transitive dependencies.

to fix this specific issue, add

DEPENDS swift-syntax-generated-headers

to lib/ClangImporter/CMakeLists.txt.

Though this is a very unsaitsfying fix because It Keeps Happening.

belkadan commented 6 years ago

That implies that we're setting it as the wrong kind of dependency at the Parse level, no? CMake knows how to deal with transitive dependencies.

harlanhaskins commented 6 years ago

The issue is that it depends on headers, which aren’t ever added to the targets, and the dependency of ClangImporter on Parse only implies it needs to link with it. So even though Parse depends on swift-syntax-generated-headers, ClangImporter doesn’t necessarily have to build Parse (and the header dependency) before building its own object files.