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-7165] Excise iostream from reflection #15677

Closed
wants to merge 5 commits into from

Conversation

nafu
Copy link
Contributor

@nafu nafu commented Apr 2, 2018

Replace iostream with raw_ostream to follow LLVM Coding Standards.
With this PR, we still use iostream for reading in tools/swift-reflection-dump/swift-reflection-dump.cpp.

Resolves SR-7165.

nafu added 5 commits April 1, 2018 11:22
…er error

This solves errors below:

```
Undefined symbols for architecture x86_64:
  "llvm::raw_ostream::write(char const*, unsigned long)", referenced from:
      _swift_reflection_dumpTypeRef in SwiftRemoteMirror.cpp.o
      _swift_reflection_dumpInfoForTypeRef in SwiftRemoteMirror.cpp.o
      _swift_reflection_dumpInfoForMetadata in SwiftRemoteMirror.cpp.o
      _swift_reflection_dumpInfoForInstance in SwiftRemoteMirror.cpp.o
      PrintTypeRef::visitNominalTypeRef(swift::reflection::NominalTypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      PrintTypeRef::visitBoundGenericTypeRef(swift::reflection::BoundGenericTypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      PrintTypeRef::visitTupleTypeRef(swift::reflection::TupleTypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      ...
  "llvm::raw_ostream::write(unsigned char)", referenced from:
      swift::reflection::TypeRef::dump() const in libswiftReflection.a(TypeRef.cpp.o)
      swift::reflection::TypeRef::dump(llvm::raw_ostream&, unsigned int) const in libswiftReflection.a(TypeRef.cpp.o)
      swift::reflection::TypeRefVisitor<PrintTypeRef, void>::visit(swift::reflection::TypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      PrintTypeRef::visitBuiltinTypeRef(swift::reflection::BuiltinTypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      PrintTypeRef::visitNominalTypeRef(swift::reflection::NominalTypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      PrintTypeRef::visitBoundGenericTypeRef(swift::reflection::BoundGenericTypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      PrintTypeRef::visitTupleTypeRef(swift::reflection::TupleTypeRef const*) in libswiftReflection.a(TypeRef.cpp.o)
      ...
  "llvm::raw_ostream::operator<<(unsigned long)", referenced from:
      llvm::raw_ostream& PrintTypeRef::printField<unsigned int>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, unsigned int const&) in libswiftReflection.a(TypeRef.cpp.o)
      swift::reflection::(anonymous namespace)::PrintTypeInfo::print(swift::reflection::TypeInfo const&) in libswiftReflection.a(TypeLowering.cpp.o)
      swift::reflection::(anonymous namespace)::PrintTypeInfo::printBasic(swift::reflection::TypeInfo const&) in libswiftReflection.a(TypeLowering.cpp.o)
      swift::reflection::TypeRefBuilder::dumpBuiltinTypeSection(llvm::raw_ostream&) in libswiftReflection.a(TypeRefBuilder.cpp.o)
      llvm::raw_ostream& PrintMetadataSource::printField<unsigned int>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, unsigned int const&) in libswiftReflection.a(MetadataSource.cpp.o)
  "llvm::errs()", referenced from:
      swift::reflection::TypeRef::dump() const in libswiftReflection.a(TypeRef.cpp.o)
      swift::reflection::TypeInfo::dump() const in libswiftReflection.a(TypeLowering.cpp.o)
      swift::reflection::ClosureContextInfo::dump() const in libswiftReflection.a(TypeRefBuilder.cpp.o)
      swift::reflection::MetadataSource::dump() const in libswiftReflection.a(MetadataSource.cpp.o)
  "llvm::outs()", referenced from:
      _swift_reflection_dumpTypeRef in SwiftRemoteMirror.cpp.o
      _swift_reflection_dumpInfoForTypeRef in SwiftRemoteMirror.cpp.o
      _swift_reflection_dumpInfoForMetadata in SwiftRemoteMirror.cpp.o
      _swift_reflection_dumpInfoForInstance in SwiftRemoteMirror.cpp.o
ld: symbol(s) not found for architecture x86_64
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
[66/711] Building CXX object lib/IRGen/CMakeFiles/swiftIRGen.dir/GenFunc.cpp.o
ninja: build stopped: subcommand failed.
./utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
```
@nafu nafu changed the title [SR-7165] Excise iostream from reflection [SR-7165][Reflection] Excise iostream from reflection Apr 2, 2018
@nafu nafu changed the title [SR-7165][Reflection] Excise iostream from reflection [SR-7165] Excise iostream from reflection Apr 2, 2018
@jckarter
Copy link
Member

jckarter commented Apr 2, 2018

Thanks! I'm not sure we can get away with using raw_ostream either, though, since some of this code gets linked into runtime libraries that don't and shouldn't link against LLVM either. It's probably best to use C printf/sprintf in most of these situations.

@slavapestov
Copy link
Member

@jckarter I don't think any part of Reflection gets linked into the runtime at the moment, and there are no plans to do so.

@slavapestov slavapestov self-requested a review April 2, 2018 21:52
@jrose-apple
Copy link
Contributor

If it's not linked into the runtime, it shouldn't live in stdlib/.

@jckarter
Copy link
Member

jckarter commented Apr 3, 2018

@slavapestov I still don't think any of Reflection's clients want to link in LLVM runtime libraries either.

@nafu
Copy link
Contributor Author

nafu commented Apr 3, 2018

It's probably best to use C printf/sprintf in most of these situations.

Can I try this one? Should I update this PR or create another PR?

@jckarter
Copy link
Member

jckarter commented Apr 3, 2018

@nafu Sure, thanks for looking into it! It's up to you whether you want to update this PR or start a new one.

@compnerd
Copy link
Collaborator

compnerd commented Apr 4, 2018

@swift-ci please test

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 4, 2018

Build failed
Swift Test OS X Platform
Git Sha - 3c17734

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 4, 2018

Build failed
Swift Test Linux Platform
Git Sha - 3c17734

@jrose-apple
Copy link
Contributor

Oops, it looks like we forgot about this one. I'm going to close the PR because the libraries have changed a lot since last year, but the bug's still available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants