ccache / ccache

ccache – a fast compiler cache
https://ccache.dev
Other
2.32k stars 496 forks source link

ccache: error: Internal error in format #568

Closed ZVNexus closed 4 years ago

ZVNexus commented 4 years ago

How to reproduce

  1. Sync AOSP
  2. Set related ccache flags
  3. Compile

https://del.dog/phucrunavu.txt

Environment

3.7.8

jrosdahl commented 4 years ago

Sorry about the problem. However, there is very little actionable information in the bug report and it's not clear what the problem actually is. Please provide more details like compiler version and OS version, etc., as requested by the bug report template.

Sync AOSP

How?

Set related ccache flags

Which flags?

Compile

How?

3.7.8 broke AOSP.

Compared to which ccache version? I.e., which ccache version works for you?

jrosdahl commented 4 years ago

The check that leads to "Internal error in format" seems dubious. It originates from 0a7cea64efef430e2bbf6329bd56ed49405ba25b but later become incorrect – it was originally an out-of-memory check but now triggers if vasprintf produces a zero-length string, for instance using format("%s", "").

With the above clue I can guess what the root cause is. Here's a way of reproducing the same crash:

touch empty.c
CCACHE_HASHDIR=1 ccache gcc -g -fdebug-prefix-map=$PWD= -c empty.c

This also exits with "ccache: error: Internal error in format" for all ccache versions between 3.3 and 3.7.8. So if this is the same problem as described in the bug report then you'll have to describe it as "going from 3.2.9 (or older) to 3.7.8 broke AOSP". :slightly_smiling_face:

Fixed in 0b1a0d78bfaac9321fc077464002bd42e6f15e5e.

ZVNexus commented 4 years ago

Sorry about the problem. However, there is very little actionable information in the bug reeport and it's not clear what the problem actually is. Please provide more details like compiler version and OS version, etc., as requested by the bug report template.

Sync AOSP

How?

Set related ccache flags

Which flags?

Compile

How?

3.7.7 worked fine, so fairly confident 3.7.8 is what broke it.

Grab build tools for AOSP https://source.android.com/setup/build/initializing

Although that's quite a bit out of date, here's a repo with some scripts that are more up to date for various distros. https://github.com/akhilnarang/scripts/tree/master/setup

From what I've gathered from other people who build AOSP or derivatives this happens on various distros, so far I've seen it happen on Ubuntu, Debian, Arch, Fedora, and what I personally use, Clear Linux.

Here are some instructions on how to set up a LOS (a derivative of AOSP), assuming you've set up your build tools above.

Here are the ccache flags for LOS that we use.

export USE_CCACHE=1 export CCACHE_DIR=${HOME}/.ccache export CCACHE_EXEC=/usr/bin/ccache

Just throw that in bashrc somewhere.

mkdir ~/LOS && cd LOS repo init -u https://github.com/LineageOS/android -b lineage-17.1 time repo sync --force-sync --no-clone-bundle --current-branch --no-tags -j$(nproc --all) . build/envsetup.sh lunch lineage_oneplus3-userdebug

It will throw an error about missing vendor, so clone this repository. git clone https://github.com/TheMuppets/proprietary_vendor_oneplus -b lineage-17.1 vendor/oneplus

Now you can actually build the target. brunch oneplus3

ZVNexus commented 4 years ago

Sorry for the lackluster initial report.

jrosdahl commented 4 years ago

3.7.7 worked fine, so fairly confident 3.7.8 is what broke it.

Thanks for the update. I think that -fdebug-prefix-map=/proc/self/cwd= in the log is key to explaining this. 3.7.8 changed so that $PWD is used instead of the return value of getcwd as the current working directory when (among other things) doing path manipulation for -fdebug-prefix-map. So 3.7.8 now actually succeeds in matching /proc/self/cwd and thus triggers the bug.

luca020400 commented 4 years ago

Thanks for the fix! I created https://bugs.archlinux.org/task/65977?project=5 to track it on Arch. Would it be possible to have a bug-fix release? Or you don't usually do that?

jrosdahl commented 4 years ago

Would it be possible to have a bug-fix release?

All 3.7.x releases are bug fix releases. I'll try to find time to make a 3.7.9 soon.

luca020400 commented 4 years ago

Would it be possible to have a bug-fix release?

All 3.7.x releases are bug fix releases. I'll try to find time to make a 3.7.9 soon.

Ok cool, glad to know.