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

C++ code doesn't compile yet, headers not found (e.g. SPM itself) #4

Open
helje5 opened this issue Aug 4, 2020 · 5 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@helje5
Copy link
Contributor

helje5 commented Aug 4, 2020

git clone https://github.com/apple/swift-package-manager.git
cd swift-package-manager
git checkout release/5.3
swift build -c release --destination \
  /usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/destination.json

Gives

In file included from /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/llvm/Support/raw_ostream.cpp:14:
In file included from /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/llvm/Support/include/llvm/Support/raw_ostream.h:17:
In file included from /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/llvm/Support/include/llvm/ADT/SmallVector.h:17:
/Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/llvm/Support/include/llvm/ADT/iterator_range.h:22:10: fatal error: 'iterator' file not found
#include <iterator>
         ^~~~~~~~~~
@helje5
Copy link
Contributor Author

helje5 commented Aug 4, 2020

One would think it is part of the libstdc++-5-dev package, but maybe it is not.

@helje5
Copy link
Contributor Author

helje5 commented Aug 4, 2020

It is

root@afca478e1ba9:/# dpkg -S /usr/include/c++/5/parallel/iterator.h
libstdc++-5-dev:amd64: /usr/include/c++/5/parallel/iterator.h

@helje5 helje5 changed the title SPM doesn't compile w/ toolchain SPM doesn't compile w/ toolchain (C++ headers missing) Aug 5, 2020
@helje5
Copy link
Contributor Author

helje5 commented Aug 5, 2020

Getting closer to get this working, but it still fails, presumably because the host compiler attempts to lookup the headers in a different location (not "c++/5").

@helje5
Copy link
Contributor Author

helje5 commented Aug 5, 2020

Sample call which fails (looks basically correct, but the -sdk is missing):

/Users/helge/dev/Swift/SPMDestinations/buildscripts/ubuntu16.04/.build/swift-5.3-ubuntu16.04.xtoolchain/swift.xctoolchain/usr/bin/clang \
  -target x86_64-unknown-linux \
  --sysroot /Users/helge/dev/Swift/SPMDestinations/buildscripts/ubuntu16.04/.build/swift-5.3-ubuntu16.04.xtoolchain/x86_64-ubuntu16.04.sdk \
  -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=libllbuild \
  -I /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/products/libllbuild/include \
  -I /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/BuildSystem/include \
  -fmodule-map-file=/Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/llbuildBuildSystem.build/module.modulemap \
  -I /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/Core/include \
  -fmodule-map-file=/Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/llbuildCore.build/module.modulemap \
  -I /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/Basic/include \
  -fmodule-map-file=/Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/llbuildBasic.build/module.modulemap \
  -I /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/llvm/Support/include \
  -fmodule-map-file=/Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/llvmSupport.build/module.modulemap \
  -I /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/lib/llvm/Demangle/include \
  -fmodule-map-file=/Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/llvmDemangle.build/module.modulemap \
  -fmodules-cache-path=/Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/ModuleCache \
  -MD -MT dependencies \
  -MF /Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/libllbuild.build/BuildKey-C-API.cpp.d \
  -std=c++14 \
  -c /Users/helge/tmp/swift-package-manager/.build/checkouts/swift-llbuild/products/libllbuild/BuildKey-C-API.cpp \
  -o /Users/helge/tmp/swift-package-manager/.build/x86_64-unknown-linux/debug/libllbuild.build/BuildKey-C-API.cpp.o

@helje5
Copy link
Contributor Author

helje5 commented Aug 5, 2020

The compilation can be fixed by adding a -I to the clang invocation. However, it doesn't work that way w/ the destination.json:

    "extra-cpp-flags": [
        "-I", "/Users/helge/dev/Swift/SPMDestinations/buildscripts/ubuntu16.04/.build/swift-5.3-ubuntu16.04.xtoolchain/swift.xctoolchain/usr/include/c++/v1",
        "-lstdc++"
    ]

The problem is that extra-cpp-flags are LINKER flags, not C PreProcessor flags nor C++ specific flags.
I don't know where clang is looking here by default, it's all linked up in both locations. Damn you SIP ...

@helje5 helje5 changed the title SPM doesn't compile w/ toolchain (C++ headers missing) C++ code doesn't compile yet, headers not found (e.g. SPM itself) Aug 5, 2020
@helje5 helje5 added bug Something isn't working help wanted Extra attention is needed labels Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant