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

cxx.features.modules crash with freestanding gcc #219

Closed
wroyca opened this issue Oct 19, 2022 · 5 comments
Closed

cxx.features.modules crash with freestanding gcc #219

wroyca opened this issue Oct 19, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@wroyca
Copy link
Contributor

wroyca commented Oct 19, 2022

Using freestanding gcc causes a crash if we enable cxx.features.modules

> /home/wroy/gcc/bin/x86_64-elf-g++ --version                                                     
x86_64-elf-g++ (GCC) 13.0.0 20221018 (experimental)
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> b config.cxx="/home/wroy/gcc/bin/x86_64-elf-g++"
libbuild2/cc/guess.cxx:3572: void build2::cc::guess_std_importable_headers(const compiler_info&, const build2::dir_paths&, importable_headers&): Assertion `p != nullptr' failed.
> gdb b core.b.1000.7b8d36aba88a4fbb90d07f1f188eddda.43115.1666200631000000
Core was generated by `b config.cxx=/home/wroy/gcc/bin/x86_64-elf-g++'.
Program terminated with signal SIGABRT, Aborted.

[Current thread is 1 (Thread 0x7fbb3bc85140 (LWP 43115))]
#0  0x00007fbb3bd20ccc in __pthread_kill_implementation () from /lib64/libc.so.6
No symbol table info available.
#1  0x00007fbb3bcd0aa6 in raise () from /lib64/libc.so.6
No symbol table info available.
#2  0x00007fbb3bcba7fc in abort () from /lib64/libc.so.6
No symbol table info available.
#3  0x00007fbb3bcba71b in __assert_fail_base.cold () from /lib64/libc.so.6
No symbol table info available.
#4  0x00007fbb3bcc9656 in __assert_fail () from /lib64/libc.so.6
No symbol table info available.
#5  0x00007fbb3c372d19 in build2::cc::guess_std_importable_headers(build2::cc::compiler_info const&, std::vector<butl::basic_path<char, butl::dir_path_kind<char> >, std::allocator<butl::basic_path<char, butl::dir_path_kind<char> > > > const&, build2::cc::importable_headers&) () from /usr/local/lib/build2/libbuild2-cc-0.16.0-a.0.18394bc05dc4-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#6  0x00007fbb3c323e4e in build2::cc::module::init(build2::scope&, build2::location const&, build2::variable_map const&, build2::cc::compiler_info const&) ()
   from /usr/local/lib/build2/libbuild2-cc-0.16.0-a.0.18394bc05dc4-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#7  0x00007fbb3c3e9f30 in build2::cxx::init(build2::scope&, build2::scope&, build2::location const&, bool, bool, build2::module_init_extra&) () 
   from /usr/local/lib/build2/libbuild2-cc-0.16.0-a.0.18394bc05dc4-0.16.0-a.0.18394bc05dc4.so
#8  0x00007fbb3c73aa96 in build2::init_module(build2::scope&, build2::scope&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, build2::location const&, bool, build2::variable_map const&) () from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#9  0x00007fbb3c790f26 in build2::parser::parse_using(build2::token&, build2::token_type&) () from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#10 0x00007fbb3c7a2d37 in build2::parser::parse_clause(build2::token&, build2::token_type&, bool) () from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#11 0x00007fbb3c7a7a6e in build2::parser::parse_buildfile(build2::lexer&, build2::scope*, build2::scope&, build2::target*, build2::prerequisite*) ()
   from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#12 0x00007fbb3c656c08 in build2::source(build2::parser&, build2::scope&, build2::scope&, build2::lexer&) () from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#13 0x00007fbb3c6617f7 in build2::source(build2::parser&, build2::scope&, build2::scope&, butl::basic_path<char, butl::any_path_kind<char> > const&) ()
   from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#14 0x00007fbb3c661b49 in build2::source_once(build2::parser&, build2::scope&, build2::scope&, butl::basic_path<char, butl::any_path_kind<char> > const&, build2::scope&) ()
   from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#15 0x00007fbb3c663288 in build2::load_root(build2::scope&, std::function<void (build2::parser&)> const&, std::function<void (build2::parser&)> const&) ()
   from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#16 0x00007fbb3c6afd71 in build2::perform_load(butl::small_vector<build2::value, 1ul> const&, build2::scope&, butl::basic_path<char, butl::any_path_kind<char> > const&, butl::basic_path<char, butl::dir_path_kind<char> > const&, butl::basic_path<char, butl::dir_path_kind<char> > const&, build2::location const&) ()
   from /usr/local/lib/build2/libbuild2-0.16.0-a.0.18394bc05dc4.so
No symbol table info available.
#17 0x0000000000412f3c in build2::main(int, char**) ()
No symbol table info available.
#18 0x00007fbb3bcbb510 in __libc_start_call_main () from /lib64/libc.so.6
No symbol table info available.
#19 0x00007fbb3bcbb5c9 in __libc_start_main_impl () from /lib64/libc.so.6
No symbol table info available.
#20 0x0000000000418495 in _start ()
No symbol table info available.
@Klaim Klaim added the bug Something isn't working label Oct 19, 2022
@boris-kolpackov
Copy link
Member

Hm, interesting. Do you have any of the headers from this list: https://github.com/build2/build2/blob/master/libbuild2/cc/guess.cxx#L3426 Perhaps <version>?

@wroyca
Copy link
Contributor Author

wroyca commented Oct 20, 2022

Hm, interesting. Do you have any of the headers from this list: https://github.com/build2/build2/blob/master/libbuild2/cc/guess.cxx#L3426 Perhaps <version>?

I do not. :)
It is reproducible with an "empty" source file, something like:

export module foo;

export auto main ([[maybe_unused]] const int argc, [[maybe_unused]] char *argv[]) {
}

@boris-kolpackov
Copy link
Member

boris-kolpackov commented Oct 21, 2022

It doesn't seem not having any std headers in freestanding is conforming: https://eel.is/c++draft/compliance Though I see <version> is not on that list. In any case, we now use <initializer_list> to discover the std header directory but also handle the case where even that is not present.

@boris-kolpackov
Copy link
Member

The fix is available in the latest staged toolchain.

@wroyca
Copy link
Contributor Author

wroyca commented Oct 21, 2022

It doesn't seem not having any std headers in freestanding is conforming:

Oops, we misunderstood each others, the compiler has the usual headers available in freestanding. Thanks for the quick fix!

@wroyca wroyca closed this as completed Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants