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

Compile error on macOS with default clang #118

Open
SimplyTheOther opened this issue Jul 18, 2019 · 8 comments
Open

Compile error on macOS with default clang #118

SimplyTheOther opened this issue Jul 18, 2019 · 8 comments
Labels
maybe-fixed A potential fix has been committed, awaiting confirmation

Comments

@SimplyTheOther
Copy link

SimplyTheOther commented Jul 18, 2019

This seems to be a different issue to the "linker issue" that was mentioned before, given that mrustc does not even compile. As such, I don't think this is a duplicate issue.

Trying to build: minicargo and mrustc itself, though makefile also makes rustc afterward
Host system version: macOS Mojave 10.14.5, x86_64-apple-darwin18.6.0
Compiler: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
mrustc version: latest commit (ebd8ede)

Note that I also changed the rustc default target to "x86_64-apple-darwin", as per recommended for non-Linux systems.

The issue seems to lie in clang not liking AST::Attribute being defined after AST::AttributeList (which includes it as the type of a vector).

Terminal output:

Theos-MacBook-Pro:mrustc-build-test theother$ gmake -f minicargo.mk CC=cc RUSTC_TARGET=x86_64-apple-darwin
gmake -f Makefile all
gmake[1]: Entering directory '/Users/theother/Documents/Repos/mrustc-build-test'
[CXX] -o .obj/main.o
In file included from src/main.cpp:8:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:500:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:644:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:660:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:1372:9: error: 
      arithmetic on a pointer to an incomplete type 'const AST::Attribute'
        ++__i;
        ^ ~~~
src/ast/attrs.hpp:50:27: note: in instantiation of member function
      'std::__1::__wrap_iter<const AST::Attribute *>::operator++' requested here
        for(const auto& i : x.m_items) {
                          ^
src/parse/token.hpp:50:11: note: forward declaration of 'AST::Attribute'
    class Attribute;
          ^
In file included from src/main.cpp:16:
In file included from src/ast/ast.hpp:21:
In file included from src/ast/types.hpp:13:
src/common.hpp:268:28: error: cannot increment value of type
      'std::__1::__wrap_iter<const AST::Attribute *>'
        for( const auto& i : v )
                           ^
src/ast/attrs.hpp:147:23: note: in instantiation of function template
      specialization 'std::operator<<<AST::Attribute>' requested here
            os << "(" << e.sub_items << ")";
                      ^
src/common.hpp:268:30: note: in implicit call to 'operator++' for iterator of
      type 'const std::__1::vector<AST::Attribute,
      std::__1::allocator<AST::Attribute> >'
        for( const auto& i : v )
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:618:54: note: 
      selected 'begin' function with iterator type
      'std::__1::vector<AST::Attribute, std::__1::allocator<AST::Attribute>
      >::const_iterator' (aka '__wrap_iter<const AST::Attribute *>')
    _LIBCPP_INLINE_VISIBILITY const_iterator         begin()   const _NOEXCEPT;
                                                     ^
2 errors generated.
gmake[1]: *** [Makefile:332: .obj/main.o] Error 1
gmake[1]: Leaving directory '/Users/theother/Documents/Repos/mrustc-build-test'
gmake: *** [minicargo.mk:53: bin/mrustc] Error 2

The error does not occur with a Homebrew-installed GCC 9.1.0, but a separate problem occurs with that, which I'll put in a different issue.

@markand
Copy link

markand commented Oct 3, 2019

Having the same on Linux with LLVM and Clang 8.0.1.

@ghost
Copy link

ghost commented Nov 4, 2019

Same problem on FreeBSD 13.0/Clang 9.0.0/libc++. Builds fine with GCC 9.2.0 but mrustc then core dumps with a Bus Error (probably the same problem as #123).

@E5ten
Copy link
Contributor

E5ten commented Nov 9, 2019

Same problem on linux with LLVM/clang/libc++ from relatively recent git master.

@thepowersgang
Copy link
Owner

thepowersgang commented Nov 10, 2019

Can't reproduce on clang version 9.0.0 (tags/RELEASE_900/final) (arch linux), but can see the issue. Issue from the above log fixed in 9976580

@thepowersgang
Copy link
Owner

Can anyone confirm that the above fix worked?

@SimplyTheOther
Copy link
Author

The original error no longer occurs with latest master (cb71402) on clang version 11.0.0 on macOS/Darwin but the macOS clang toolchain still fails to build mrustc due to issues with ar:

...
[CXX] -o .obj/version.o
[AR] -o bin/mrustc.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: illegal option -- D
usage:  ar -d [-TLsv] archive file ...
	ar -m [-TLsv] archive file ...
	ar -m [-abiTLsv] position archive file ...
	ar -p [-TLsv] archive [file ...]
	ar -q [-cTLsv] archive file ...
	ar -r [-cuTLsv] archive file ...
	ar -r [-abciuTLsv] position archive file ...
	ar -t [-TLsv] archive [file ...]
	ar -x [-ouTLsv] archive [file ...]
gmake[1]: *** [Makefile:283: bin/mrustc.a] Error 1
gmake[1]: Leaving directory '/Users/theother/Documents/Repos/mrustc-build-test'
gmake: *** [minicargo.mk:60: bin/mrustc] Error 2
192-168-1-107:mrustc-build-test theother$

@thepowersgang
Copy link
Owner

#151 has some fixes that I've yet to review/merge

@thepowersgang
Copy link
Owner

ar options were updated in 3924a68, should now be fixed.

@thepowersgang thepowersgang added the maybe-fixed A potential fix has been committed, awaiting confirmation label Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maybe-fixed A potential fix has been committed, awaiting confirmation
Projects
None yet
Development

No branches or pull requests

4 participants