Opened 3 years ago

Last modified 2 years ago

#63645 new defect

building libqalculate @3.21.0 makes clang-10 @10.0.1_5 hit an assertion failure

Reported by: cooljeanius (Eric Gallager) Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: Cc: jjstickel (Jonathan Stickel), judaew (Vadym-Valdis Yudaiev), jeremyhu (Jeremy Huddleston Sequoia)
Port: libqalculate, clang-10, llvm-10

Description

It looks like there also might be a problem with UsingTheRightCompiler, too:

Executing:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0" && /usr/bin/make -j16 -w all 
DEBUG: system:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0" && /usr/bin/make -j16 -w all 
make: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0'
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
make[1]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0'
Making all in po-defs
make[2]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0/po-defs'
g++ -g -O2    remove-untranslated.cc   -o fixpo
Assertion failed: (!CreatedADWARFSection && "Creating regular section after DWARF"), function ChangeSection, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_llvm-10/llvm-10/work/llvm-10.0.1.src/lib/MC/MCMachOStreamer.cpp, line 158.
Stack dump:
0.	Program arguments: /opt/local/libexec/llvm-10/bin/clang -cc1as -triple x86_64-apple-macosx11.0.0 -filetype obj -main-file-name ccAO8WhT.s -target-cpu penryn -fdebug-compilation-dir /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0/po-defs -dwarf-debug-producer clang version 10.0.1  -dwarf-version=4 -mrelocation-model pic -o /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/.tmp/ccX2kOy9.o /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/.tmp/ccAO8WhT.s 
0  libLLVM.dylib            0x00000001074efa34 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  libLLVM.dylib            0x00000001074efe20 SignalHandler(int) + 208
2  libsystem_platform.dylib 0x00007fff203eed7d _sigtramp + 29
3  libsystem_platform.dylib 0x00007fa0d740a400 _sigtramp + 18446743668758001312
4  libsystem_c.dylib        0x00007fff202fe406 abort + 125
5  libsystem_c.dylib        0x00007fff202fd7d8 err + 0
6  libLLVM.dylib            0x00000001096309a8 (anonymous namespace)::MCMachOStreamer::ChangeSection(llvm::MCSection*, llvm::MCExpr const*) (.cold.4) + 0
7  libLLVM.dylib            0x00000001081f532a (anonymous namespace)::MCMachOStreamer::ChangeSection(llvm::MCSection*, llvm::MCExpr const*) + 676
8  libLLVM.dylib            0x00000001082041b4 llvm::MCStreamer::SwitchSection(llvm::MCSection*, llvm::MCExpr const*) + 96
9  libLLVM.dylib            0x0000000108240a43 (anonymous namespace)::DarwinAsmParser::parseSectionSwitch(llvm::StringRef, llvm::StringRef, unsigned int, unsigned int, unsigned int) + 195
10 libLLVM.dylib            0x000000010824127e bool llvm::MCAsmParserExtension::HandleDirective<(anonymous namespace)::DarwinAsmParser, &((anonymous namespace)::DarwinAsmParser::parseSectionDirectiveModInitFunc(llvm::StringRef, llvm::SMLoc))>(llvm::MCAsmParserExtension*, llvm::StringRef, llvm::SMLoc) + 44
11 libLLVM.dylib            0x0000000108229fc0 (anonymous namespace)::AsmParser::parseStatement((anonymous namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) + 2758
12 libLLVM.dylib            0x0000000108225b87 (anonymous namespace)::AsmParser::Run(bool, bool) + 395
13 clang                    0x0000000105310cac cc1as_main(llvm::ArrayRef<char const*>, char const*, void*) + 10104
14 clang                    0x000000010530b7a0 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 542
15 clang                    0x000000010530b465 main + 7760
16 libdyld.dylib            0x00007fff203c4f3d start + 1
clang: error: unable to execute command: Abort trap: 6
clang: error: clang integrated assembler command failed due to signal (use -v to see invocation)
clang version 10.0.1 
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-10/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
make[2]: *** [fixpo] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0/po-defs'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0'
make: *** [all] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_libqalculate/libqalculate/work/libqalculate-3.21.0" && /usr/bin/make -j16 -w all 
Exit code: 2
Error: Failed to build libqalculate: command execution failed
DEBUG: Error code: CHILDSTATUS 34114 2

Is this something that should be reported upstream?

Also, note that my clang-10 port is installed with neither the +assertions nor the +debug variants:

$ port installed clang-10
The following ports are currently installed:
  clang-10 @10.0.1_5+analyzer+libstdcxx (active)

I guess llvm-10 does have the +debug variant active, though:

$ port installed llvm-10
The following ports are currently installed:
  llvm-10 @10.0.1_2+debug+ocaml+polly (active)

Attachments (4)

libqalculate_main.log (31.4 KB) - added by cooljeanius (Eric Gallager) 2 years ago.
main.log for libqalculate
remove-untranslated.ii (992.3 KB) - added by cooljeanius (Eric Gallager) 2 years ago.
preprocessed source causing the assembler crash
remove-untranslated.s (424.6 KB) - added by cooljeanius (Eric Gallager) 2 years ago.
assembly causing the assembler crash
gcc_configure_flags.diff (1.5 KB) - added by cooljeanius (Eric Gallager) 2 years ago.
diff between the configure flags I use for GCC and the configure flags that MacPorts uses for it

Download all attachments as: .zip

Change History (11)

Changed 2 years ago by cooljeanius (Eric Gallager)

Attachment: libqalculate_main.log added

main.log for libqalculate

comment:1 Changed 2 years ago by cooljeanius (Eric Gallager)

port select output that might be relevant:

$ port select gcc
Available versions for gcc:
	mp-gcc10 (active)
	mp-gcc11
	mp-gcc8
	mp-gcc9
	none
$ port select clang
Available versions for clang:
	mp-clang-10
	mp-clang-11
	mp-clang-12
	mp-clang-13
	mp-clang-9.0 (active)
	none
$ port select llvm
Available versions for llvm:
	mp-llvm-10
	mp-llvm-11
	mp-llvm-12
	mp-llvm-13
	mp-llvm-3.3
	mp-llvm-3.4
	mp-llvm-3.7
	mp-llvm-5.0
	mp-llvm-6.0
	mp-llvm-7.0
	mp-llvm-8.0
	mp-llvm-9.0 (active)
	none
$

comment:2 Changed 2 years ago by cooljeanius (Eric Gallager)

Building with trace mode on allows the build to succeed. Some trace mode output that might be relevant:

configure step:

Warning: The following existing files were hidden from the build system by trace mode:
  /opt/local/bin/ar
  /opt/local/bin/g++-mp-10
  /opt/local/bin/gawk
  /opt/local/bin/gcc-mp-10
  /opt/local/bin/ggrep
  /opt/local/bin/gmkdir
  /opt/local/bin/gsed
  /opt/local/bin/lipo
  /opt/local/bin/mawk
  /opt/local/bin/nawk
  /opt/local/bin/nm
  /opt/local/bin/nmedit
  /opt/local/bin/otool
  /opt/local/bin/ranlib
  /opt/local/bin/strip
  /opt/local/include/Block.h
  /opt/local/lib/libunwind.dylib
  /opt/local/lib/perl5/vendor_perl/5.30/darwin-thread-multi-2level/Time/HiRes.pm
  /opt/local/lib/perl5/vendor_perl/5.30/darwin-thread-multi-2level/XSLoader.pm
  /private/var/select/sh
Warning: The following files inside the MacPorts prefix not installed by a port were accessed:
  /opt/local/bin/g++
  /opt/local/bin/gcc

build step:

Warning: The following existing files were hidden from the build system by trace mode:
  /opt/local/bin/SCCS
  /opt/local/bin/ar
  /opt/local/bin/g++-mp-10
  /opt/local/bin/ranlib
  /opt/local/lib/libunwind.dylib
  /opt/local/lib/perl5/vendor_perl/5.30/Text/Tabs.pm
  /opt/local/lib/perl5/vendor_perl/5.30/Text/Wrap.pm
  /opt/local/lib/perl5/vendor_perl/5.30/darwin-thread-multi-2level/XSLoader.pm
  /private/var/select/sh
Warning: The following files inside the MacPorts prefix not installed by a port were accessed:
  /opt/local/bin/g++
  /opt/local/include/libxml2/unicode/localpointer.h
  /opt/local/include/libxml2/unicode/platform.h
  /opt/local/include/libxml2/unicode/ptypes.h
  /opt/local/include/libxml2/unicode/putil.h
  /opt/local/include/libxml2/unicode/stringoptions.h
  /opt/local/include/libxml2/unicode/ucasemap.h
  /opt/local/include/libxml2/unicode/ucnv_err.h
  /opt/local/include/libxml2/unicode/uconfig.h
  /opt/local/include/libxml2/unicode/uenum.h
  /opt/local/include/libxml2/unicode/uiter.h
  /opt/local/include/libxml2/unicode/umachine.h
  /opt/local/include/libxml2/unicode/urename.h
  /opt/local/include/libxml2/unicode/ustring.h
  /opt/local/include/libxml2/unicode/utf.h
  /opt/local/include/libxml2/unicode/utf16.h
  /opt/local/include/libxml2/unicode/utf8.h
  /opt/local/include/libxml2/unicode/utf_old.h
  /opt/local/include/libxml2/unicode/utypes.h
  /opt/local/include/libxml2/unicode/uvernum.h
  /opt/local/include/libxml2/unicode/uversion.h

destroot step:

Warning: The following existing files were hidden from the build system by trace mode:
  /opt/local/bin/SCCS
  /opt/local/bin/ranlib
  /private/var/select/sh
  /var/root/.CFUserTextEncoding
Warning: The following files inside the MacPorts prefix not installed by a port were accessed:
  /opt/local/include/libxml2/unicode/localpointer.h
  /opt/local/include/libxml2/unicode/platform.h
  /opt/local/include/libxml2/unicode/ptypes.h
  /opt/local/include/libxml2/unicode/putil.h
  /opt/local/include/libxml2/unicode/stringoptions.h
  /opt/local/include/libxml2/unicode/ucasemap.h
  /opt/local/include/libxml2/unicode/ucnv_err.h
  /opt/local/include/libxml2/unicode/uconfig.h
  /opt/local/include/libxml2/unicode/uenum.h
  /opt/local/include/libxml2/unicode/uiter.h
  /opt/local/include/libxml2/unicode/umachine.h
  /opt/local/include/libxml2/unicode/urename.h
  /opt/local/include/libxml2/unicode/ustring.h
  /opt/local/include/libxml2/unicode/utf.h
  /opt/local/include/libxml2/unicode/utf16.h
  /opt/local/include/libxml2/unicode/utf8.h
  /opt/local/include/libxml2/unicode/utf_old.h
  /opt/local/include/libxml2/unicode/utypes.h
  /opt/local/include/libxml2/unicode/uvernum.h
  /opt/local/include/libxml2/unicode/uversion.h

readlink /opt/local/bin/g++ says it points to /opt/local/bin/g++-mp-10, so, I guess since clang is what's crashing, it must be because gcc is configured to use clang's assembler or linker or something?

Changed 2 years ago by cooljeanius (Eric Gallager)

Attachment: remove-untranslated.ii added

preprocessed source causing the assembler crash

Changed 2 years ago by cooljeanius (Eric Gallager)

Attachment: remove-untranslated.s added

assembly causing the assembler crash

comment:3 Changed 2 years ago by kencu (Ken)

I reported this bug upstream a few years ago; no traction yet!

https://bugs.llvm.org/show_bug.cgi?id=41840

comment:4 Changed 2 years ago by cooljeanius (Eric Gallager)

I've been discussing this bug on GCC's IRC: https://gcc.gnu.org/wiki/GCConIRC

In testing, I've found that all my installed versions of GCC from MacPorts (8, 9, 10, and 11) cause this assembler crash, but my hand-installed version of GCC trunk doesn't cause the crash, though, so I'm wondering if it's due to some sort of difference in how MacPorts configures GCC compared to how I configure it... are all of the configure flags that MacPorts uses for GCC really necessary? I'll attach a diff between the configure flags I use for GCC and the configure flags MacPorts uses for GCC next...

Changed 2 years ago by cooljeanius (Eric Gallager)

Attachment: gcc_configure_flags.diff added

diff between the configure flags I use for GCC and the configure flags that MacPorts uses for it

comment:5 Changed 2 years ago by kencu (Ken)

if you use your hand-rolled gcc but force it to use MacPorts' clang as the assembler (and the clang that is being used as the assembler has assertions turned on) you will undoubtedly get the exact same error.

I believe it has absolutely nothing to do with gcc, or with the way MacPorts builds gcc.

It has everything to do with any version of gcc using "gcc -g" putting out assembly that clang with assertions turned on will not assemble.

Also nothing to do with qalculate or libqalculate -- those are just building wrong, using g++ that on your system happens to point to a gcc, and they have "-g" added, and you are using a MacPorts clang as your assembler, and that MacPorts clang happens to have assertions turned on.

:>

Which is why we see this particular issue relatively rarely.

Last edited 2 years ago by kencu (Ken) (previous) (diff)

comment:6 Changed 2 years ago by kencu (Ken)

I doubt gcc wants to (or should) change their assembly. Clang has apparently already agreed that they should someday get around to fixing this.

comment:7 Changed 2 years ago by iains

If GCC"s output is buggy - then sure we'd want to fix it.

In this particular case, we emit:

	.section __TEXT,__text_cold,regular,pure_instructions
Letext_cold0:

but no content (this is a trailing symbol signifying the end of the section)

The .section __TEXT,__text_cold,regular,pure_instructions has been previously used (before any DWARF sections), so the section should be ordered before the __DWARF segment stuff in the mach-o .o file.

So, in this specific case, AFAIU the intended operation of the assembler, this is a false positive.


However, GCC does use other sections that are not "whitelisted" in static bool canGoAfterDWARF(const MCSectionMachO &MSec) from lib/MC/MCMachOStreamer.cpp. Some of these (e.g. the streamed LTO IR) can safely follow DWARF sections so perhaps we should reach some agreement on this and submit a patch to whitelist those.

It also looks like mod_init/term_funcs sections are not whitelisted - and we definitely emit those late. I do have some initial patches somewhere to allow more control over the ordering - but they are not too high on the current TODO.

Last edited 2 years ago by iains (previous) (diff)
Note: See TracTickets for help on using tickets.