mrustc
mrustc copied to clipboard
Compile error on macOS with default clang
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.
Having the same on Linux with LLVM and Clang 8.0.1.
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).
Same problem on linux with LLVM/clang/libc++ from relatively recent git master.
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 9976580f96b3fd10d90250f9d977e44e2ab9198d
Can anyone confirm that the above fix worked?
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$
#151 has some fixes that I've yet to review/merge
ar
options were updated in 3924a6871f5039ca1d00aaa76459cbd100b8e5ff, should now be fixed.