<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/68796>68796</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Possible solutions to "out of memory... Allocation failed"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ElectricPulse
      </td>
    </tr>
</table>

<pre>
    I am building GCC (branch devel/omp/gcc-13) in the wacky chroot like enviroment of Termux on Android 13 using clang.

Config
```
export CPPFLAGS='-U __ANDROID_API__ -D __ANDROID_API__=33 --target=aarch64-linux-android33'; ../trunk/configure --prefix=/data/data/com.termux/files/usr --enable-languages=c,c++,fortran --target=aarch64-linux-android33
```

During compilation of the gcc binary I encounter the following crash:

```
Stack dump:
0.      Program arguments: g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-strict-aliasing -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -fno-PIE -I. -I. -I../../trunk/gcc -I../../trunk/gcc/. -I../../trunk/gcc/../include -I./../intl -I../../trunk/gcc/../libcpp/include -I../../trunk/gcc/../libcody -I../../trunk/gcc/../libdecnumber -I../../trunk/gcc/../libdecnumber/bid -I../libdecnumber -I../../trunk/gcc/../libbacktrace -U __ANDROID_API__ -D __ANDROID_API__=33 --target=aarch64-linux-android33 -I/data/data/com.termux/files/usr/include -o generic-match-9.o -MT generic-match-9.o -MMD -MP -MF ./.deps/generic-match-9.TPo generic-match-9.cc 1.      <eof> parser at end of file
2.      Code generation                                    3. Running pass 'Function Pass Manager' on module 'generic-match-9.cc'. 4.      Running pass 'Assignment Tracking Analysis' on function '@_Z29generic_simplify_BIT_IOR_EXPRj9tree_codeP9tree_nodeS1_S1_'
g++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 17.0.2 Target: aarch64-unknown-linux-android33
Thread model: posix InstalledDir: /data/data/com.termux/files/usr/bin
```
...later
```
mprotect failed on atexit array: Out of memory
> make[2]: *** [Makefile:1189: generic-match-9.o] Aborted    make[2]: Leaving directory '/data/- - - # [ ] data/com.termux/files/home/ProjectO/gcc/build/gcc' make[1]: *** [Makefile:4659: all-gcc] Error 2
make[1]: Leaving directory '/data/data/com.termux/files/home/ProjectO/gcc/build'
make: *** [Makefile:1055: all] Error 2                       
```

>From experience I am more than sure that enough memory is available, because the whole system has enough memory and because I gave Termux wakelock permissions. But I have no idea how to check if Termux itself can allocate more memory and prove my assumption.
The auto generated minimal code example is attached.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysV1tz4joS_jXipUsuI4cQHnhwIMyh6mRCJcxmd1-ottzYOsiSV5JJ-PdbsmEmkzlzq13iBLvdd319CXqvKkM0Z5NbNlmOsAu1dfM7TTI4JTed9jQqbHmarwEbKDqlS2Uq-LBYABM3hUMjayjpSJqJlW1aJlaVlHycMTEDZSDUBC8oDyeQtbM2gFYHAjJH5WxDJoDdw5Zc072CNZCb0llVwjiDzkc7UqOpEpbmLM0X1uxVFe-v0_OV5vTaWhdgsdms_sw_PLFsycSUf4LdLv-4fHxYL3f5Zr3bAV--J7FsmWXAeUBXUWDZEtHJ-vqKa2W6V46DK1nGxJRlt5AkTKyC68yBiZXsXekcAeeto7167Q2vSgz45UvaJgl9bEys9kqTZ2LVeQeck8FCE4_RdViRZ9lSMrGQTNz212JvXXBofsW_rxPC0nzZuT53tmmVxqCsiVmOJ1FJCYUy6E6wBjLSdiaQ61_trdb2pZdz6GuW5YOyt7qfAsoDlF3TDq_TBPrPxtnKYQPoqi4eqmdZDtUQC_C9sXyzvgMugVfAHwTw5frjLkKILxePD09Pu-X68W6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