<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WebAssembly fails to build due to -fpermissive on linux + gcc 7.2.0"
   href="https://bugs.llvm.org/show_bug.cgi?id=38512">38512</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>WebAssembly fails to build due to -fpermissive on linux + gcc 7.2.0
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Build scripts
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>cmake
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gonzalobg88@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The bash script below is how compiler-explorer builds clang.

When trying to enable the WebAssembly target by switching from:

    -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="RISCV"

to

    -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="RISCV;WebAssembly"

the build fails (Linux, GCC 7.2.0):

                                                          ```^
make[2]: ***
[lib/Target/WebAssembly/CMakeFiles/LLVMWebAssemblyCodeGen.dir/WebAssemblyCFGSort.cpp.o]
Error 1
make[1]: *** [lib/Target/WebAssembly/CMakeFiles/LLVMWebAssemblyCodeGen.dir/all]
Error 2
make[1]: *** Waiting for unfinished jobs....```
```/root/llvm/lib/Target/WebAssembly/WebAssemblyCFGSort.cpp:215:17: error:
declaration of 'const {anonymous}::Region* {anonymous}::Entry::Region'
[-fpermissive]
   const Region *Region;
                 ^~~~~~
/root/llvm/lib/Target/WebAssembly/WebAssemblyCFGSort.cpp:41:7: error: changes
meaning of 'Region' from 'class {anonymous}::Region' [-fpermissive]
 class Region {```


Is this a bug in the build script? Or is there anything that we are doing wrong
while configuring and building the llvm projects from trunk?

My workaround would be to use: "-DCMAKE_CXX_FLAGS=-fpermissive". Does that make
sense for the time being?

----

#!/bin/bash

set -ex

# Grab CE's GCC 7.2.0 for its binutils (which is what the site uses to link
currently)
mkdir -p /opt/compiler-explorer
pushd /opt/compiler-explorer
curl -sL <a href="https://s3.amazonaws.com/compiler-explorer/opt/gcc-7.2.0.tar.xz">https://s3.amazonaws.com/compiler-explorer/opt/gcc-7.2.0.tar.xz</a> | tar
Jxf -
popd

ROOT=$(pwd)
VERSION=$1
LLVM_BASE=<a href="http://llvm.org/svn/llvm-project">http://llvm.org/svn/llvm-project</a>
if echo ${VERSION} | grep 'trunk'; then
    TAG=trunk
    VERSION=trunk-$(date +%Y%m%d)
    POLLY_BRANCH=master
else
    SPLIT=(${VERSION//-/ })
    VERSION=${SPLIT[0]}
    VSN=$(echo ${VERSION} | sed 's/\.//g')
    TAG=tags/RELEASE_${VSN}/${SPLIT[1]-final}
    POLLY_BRANCH=release_${VSN:0:2}
fi

OUTPUT=/root/clang-${VERSION}.tar.xz
S3OUTPUT=""
if echo $2 | grep s3://; then
    S3OUTPUT=$2
else
    OUTPUT=${2-/root/clang-${VERSION}.tar.xz}
fi

STAGING_DIR=$(pwd)/staging
rm -rf ${STAGING_DIR}
mkdir -p ${STAGING_DIR}

svn co -q ${LLVM_BASE}/llvm/${TAG} llvm
git clone -b ${POLLY_BRANCH} <a href="https://llvm.org/git/polly.git">https://llvm.org/git/polly.git</a> llvm/tools/polly
pushd llvm/tools
svn co -q ${LLVM_BASE}/cfe/${TAG} clang
popd
pushd llvm/tools/clang/tools
svn co -q ${LLVM_BASE}/clang-tools-extra/${TAG} extra
popd
pushd llvm/projects
svn co -q ${LLVM_BASE}/libcxx/${TAG} libcxx
svn co -q ${LLVM_BASE}/libcxxabi/${TAG} libcxxabi
svn co -q ${LLVM_BASE}/compiler-rt/${TAG} compiler-rt
popd

mkdir build
cd build
cmake -G "Unix Makefiles" ../llvm \
    -DCMAKE_BUILD_TYPE:STRING=Release \
    -DCMAKE_INSTALL_PREFIX:PATH=/root/staging \
   
-DLLVM_BINUTILS_INCDIR:PATH=/opt/compiler-explorer/gcc-7.2.0/lib/gcc/x86_64-linux-gnu/7.2.0/plugin/include/
\
    -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="RISCV;WebAssembly"

make -j$(nproc) install

# Don't try to compress the binaries as they don't like it

export XZ_DEFAULTS="-T 0"
tar Jcf ${OUTPUT} --transform "s,^./,./clang-${VERSION}/," -C ${STAGING_DIR} .

if [[ ! -z "${S3OUTPUT}" ]]; then
    s3cmd put --rr ${OUTPUT} ${S3OUTPUT}
fi</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>