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

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

Open
catap opened this issue Feb 15, 2022 · 6 comments
Open
Labels
I-ccompiler A bug in the downstream C compiler

Comments

@catap
Copy link
Contributor

catap commented Feb 15, 2022

Environment: macOS 10.15, mrustc from 87b7481 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
@thepowersgang
Copy link
Owner

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.

@catap
Copy link
Contributor Author

catap commented Feb 18, 2022

@thepowersgang any idea how can I do it?

@thepowersgang
Copy link
Owner

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

@bjorn3
Copy link
Contributor

bjorn3 commented Feb 18, 2022

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.

@catap
Copy link
Contributor Author

catap commented Feb 19, 2022

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?

@bjorn3
Copy link
Contributor

bjorn3 commented Feb 20, 2022

Not sure.

@thepowersgang thepowersgang added the I-ccompiler A bug in the downstream C compiler label Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ccompiler A bug in the downstream C compiler
Projects
None yet
Development

No branches or pull requests

3 participants