mrustc icon indicating copy to clipboard operation
mrustc copied to clipboard

mrustc produces a code which compiling hours by Apple Clang 12 (and below)

Open catap opened this issue 2 years ago • 6 comments

Environment: macOS 10.15, mrustc from 87b7481c54b7cb4379cdb5126a2cf7cf9a4f9b83 and rustc-1.54.0-src with additional patch https://github.com/catap/rust-legacy-bootstrap/blob/master/rustc-1.54.0-src.patch.

Bootstrapping rust requires incredible time like couple of hours.

The root cause is compiling libaho_corasick-0_7_13_H1.rlib.c. Just to compare a time which is required to compile aho_corasick on macOS 11 and macOS 10.15 via Github CI:

macOS 10.15: 153514594-7fa2a677-e5fa-44a3-b227-cb6b9fbda2d7

macOS 11: 153514549-172c5bab-eadc-4717-92d6-4fe51ad67174

I've installed to this machine a few clangs: 10, 11, 12 and 13 and made small test which contains simpler args:

#!/bin/sh

for c in clang clang-mp-{10,11,12,13}
do
      echo Use clang
      $c --version
      echo ...
      timeout -v 30 time $c -cc1 \
            -emit-obj \
            -fgnuc-version=4.2.1 \
            -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0 \
            -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk \
            -I/opt/local/libexec/openssl11/include \
            -I/opt/local/include \
            -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/local/include \
            -internal-isystem /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include \
            -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include \
            -internal-externc-isystem /Library/Developer/CommandLineTools/usr/include \
            -O2 \
            -o libaho_corasick-0_7_13_H1.rlib.o \
            -x c \
            libaho_corasick-0_7_13_H1.rlib.c
done

an output:

Use clang
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
...
timeout: sending signal TERM to command ‘time’
Use clang
clang version 10.0.1 
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-10/bin
...
        4.82 real         4.71 user         0.09 sys
Use clang
clang version 11.1.0
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-11/bin
...
        4.70 real         4.59 user         0.09 sys
Use clang
clang version 12.0.1
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-12/bin
...
        3.87 real         3.77 user         0.08 sys
Use clang
clang version 13.0.1
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-13/bin
...
        4.16 real         4.03 user         0.09 sys

catap avatar Feb 15 '22 22:02 catap

If this file takes that long in clang, then that's a clang bug.

If you can determine what function it's choking on and a way to reduce it's complexity, then that'd be useful.

thepowersgang avatar Feb 18 '22 09:02 thepowersgang

@thepowersgang any idea how can I do it?

catap avatar Feb 18 '22 11:02 catap

No idea at all - as said, this is a clang issue (the file, at least on my builds) isn't that big (6.1M)

thepowersgang avatar Feb 18 '22 11:02 thepowersgang

Clang 9 introduced -ftime-trace which produces profiles compatible with chrome's chrome://tracing: https://reviews.llvm.org/rGd880de2d19d46f7cfea7aa593602458440bc1e8d If you don't use chrome, I believe firefox's profiler (profiler.firefox.com) can also load them. Speedscope also accepts them.

bjorn3 avatar Feb 18 '22 13:02 bjorn3

For records: mrustc-255.zip

libaho_corasick-0_7_13_H1.rlib-clang.json is a file which was produced by Apple Clang which runs 101 minute and all time was spent inside RunPass {"detail":"Combine redundant instructions"}

I have no idea how to debug it future. @bjorn3 any thoughts?

catap avatar Feb 19 '22 23:02 catap

Not sure.

bjorn3 avatar Feb 20 '22 09:02 bjorn3