From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id D20093857825 for ; Mon, 20 Jun 2022 15:41:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D20093857825 Received: by mail-lf1-x12a.google.com with SMTP id i18so4239525lfu.8 for ; Mon, 20 Jun 2022 08:41:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/e8lHn6xqrNYnmWfRrKktHREQfE84wpgPBs1YE21fEM=; b=KxBCy9jERv7j2VOH7k+uCM9jqxUcyg0Jp6A7qQHoM8GuitY7fb1UiO3USeIldJakwT satpj+XmXjc4gNo9OcbaYiVt2o3kze9sVKWXzcRzbuwVujSiIMlahGptKe+Xh1UymUsr 8WhOplf+J0qWEgNX54Fom6TybLrXDzEu3MbTy2XsP6qoztJ7R/dqnc+Z0qgmEIz94JMV 3Fq4faHdXg7BoNwgE75dGEWouvWar7OPTRDa/UP9l1vxXDUDot9rh3xV0ooE3KnhO8MK Rqj7d2kUxXVbiw17Q16p2+kXhufbFZLu49nbbI1I+ZNImG5qmGEn3azykN53a74ckPZo oL9g== X-Gm-Message-State: AJIora/ahF/LHrAFMLgLRvTwXqrMT9Qt++w41IFEr+XjyNOW7hRsHssQ 9TjUczi7AmfMViiqtr7GaScc9w0M6w1KHqTY+WC7q2rsDvQ= X-Google-Smtp-Source: AGRyM1tAl49JktADAN6Wa8C62bZMbngrdInYx3Kb3UmuNkHmiGjJjbKhF/I90XhNxN1wAA+rTrB1V1bblb7EX3atJtY= X-Received: by 2002:a05:6512:685:b0:479:176c:5a5e with SMTP id t5-20020a056512068500b00479176c5a5emr13658681lfe.408.1655739693765; Mon, 20 Jun 2022 08:41:33 -0700 (PDT) MIME-Version: 1.0 From: Andrew Ho Date: Mon, 20 Jun 2022 08:41:22 -0700 Message-ID: Subject: Building gcc with AMD offloading fails building libssp To: gcc-help@gcc.gnu.org X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2022 15:41:38 -0000 Hi, I'm trying to build GCC 12.1.0 with amdgcn-amdhsa offload support, but I'm running into a problem when it tries to compile libssp. I am on Ubuntu 20.04.1 LTS, and have an AMD RX 480 gpu. The compiler I'm using to try and build gcc with is the one which comes with Ubuntu (9.4.0). I checked out the git repo on tag releases/gcc-12.1.0, and softlinked the following files from AMD's rocm installed llvm: ln -s /opt/rocm/llvm/bin/llvm-ar $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/gcc-bin/12.1.0/ar ln -s /opt/rocm/llvm/bin/llvm-mc $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/gcc-bin/12.1.0/as ln -s /opt/rocm/llvm/bin/lld $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/gcc-bin/12.1.0/ld ln -s /opt/rocm/llvm/bin/llvm-ar $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/gcc-bin/12.1.0/ranlib Configure and build command: ${gccsrc}/configure --target=3Damdgcn-amdhsa --disable-sjlj-exceptions --with-newlib --enable-as-accelerator-for=3Dx86_64-pc-linux-gnu --with-build-time-tools=3D$HOME/opt/gcc/12.1.0/amdgcn-amdhsa/gcc-bin/12.1.0 --prefix=3D$HOME/opt/gcc/12.1.0 --enable-languages=3Dc,lto,c++,fortran --enable-libgomp make When it tries to compile gcc/libssp/ssp.c, it can't find some common C functions/types: make[3]: Entering directory '${gccobj}/amdgcn-amdhsa/libssp' /bin/bash ./libtool --tag=3DCC --mode=3Dcompile ${gccobj}/./gcc/xgcc -B${gccobj}/./gcc/ -B$HOME/opt/gcc/12.1.0/amdgcn-amdhsa/bin/ -B$HOME/opt/gcc/12.1.0/amdgcn-amdhsa/lib/ -isystem $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/include -isystem $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/sys-include -DHAVE_CONFIG_H -I. -I../../../gcc/libssp -Wall -g -O2 -MT ssp.lo -MD -MP -MF .deps/ssp.Tpo -c -o ssp.lo ../../../gcc/libssp/ssp.c libtool: compile: ${gccobj}/./gcc/xgcc -B${gccobj}/./gcc/ -B$HOME/opt/gcc/12.1.0/amdgcn-amdhsa/bin/ -B$HOME/opt/gcc/12.1.0/amdgcn-amdhsa/lib/ -isystem $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/include -isystem $HOME/opt/gcc/12.1.0/amdgcn-amdhsa/sys-include -DHAVE_CONFIG_H -I. -I../../../gcc/libssp -Wall -g -O2 -MT ssp.lo -MD -MP -MF .deps/ssp.Tpo -c ../../../gcc/libssp/ssp.c -o ssp.o ../../../gcc/libssp/ssp.c: In function =E2=80=98__guard_setup=E2=80=99: ../../../gcc/libssp/ssp.c:93:12: warning: implicit declaration of function =E2=80=98open=E2=80=99 [-Wimplicit-function-declaration] 93 | int fd =3D open ("/dev/urandom", O_RDONLY); | ^~~~ ../../../gcc/libssp/ssp.c:93:34: error: =E2=80=98O_RDONLY=E2=80=99 undeclar= ed (first use in this function) 93 | int fd =3D open ("/dev/urandom", O_RDONLY); | ^~~~~~~~ ../../../gcc/libssp/ssp.c:93:34: note: each undeclared identifier is reported only once for each function it appears in ../../../gcc/libssp/ssp.c:96:7: error: unknown type name =E2=80=98ssize_t= =E2=80=99 96 | ssize_t size =3D read (fd, &__stack_chk_guard, | ^~~~~~~ ../../../gcc/libssp/ssp.c:96:22: warning: implicit declaration of function =E2=80=98read=E2=80=99 [-Wimplicit-function-declaration] 96 | ssize_t size =3D read (fd, &__stack_chk_guard, | ^~~~ ../../../gcc/libssp/ssp.c:98:7: warning: implicit declaration of function =E2=80=98close=E2=80=99 [-Wimplicit-function-declaration] 98 | close (fd); | ^~~~~ ../../../gcc/libssp/ssp.c: At top level: ../../../gcc/libssp/ssp.c:113:25: error: unknown type name =E2=80=98size_t= =E2=80=99 113 | fail (const char *msg1, size_t msg1len, const char *msg3) | ^~~~~~ ../../../gcc/libssp/ssp.c:36:1: note: =E2=80=98size_t=E2=80=99 is defined i= n header =E2=80=98=E2=80=99; did you forget to =E2=80=98#include =E2=80=99? 35 | #include "config.h" +++ |+#include 36 | #ifdef HAVE_ALLOCA_H ../../../gcc/libssp/ssp.c: In function =E2=80=98__stack_chk_fail=E2=80=99: ../../../gcc/libssp/ssp.c:185:3: warning: implicit declaration of function =E2=80=98fail=E2=80=99 [-Wimplicit-function-declaration] 185 | fail (msg, strlen (msg), "stack smashing detected: terminated"); | ^~~~ ../../../gcc/libssp/ssp.c:185:14: warning: implicit declaration of function =E2=80=98strlen=E2=80=99 [-Wimplicit-function-declaration] 185 | fail (msg, strlen (msg), "stack smashing detected: terminated"); | ^~~~~~ ../../../gcc/libssp/ssp.c:36:1: note: include =E2=80=98=E2=80=99 = or provide a declaration of =E2=80=98strlen=E2=80=99 35 | #include "config.h" +++ |+#include 36 | #ifdef HAVE_ALLOCA_H ../../../gcc/libssp/ssp.c:185:14: warning: incompatible implicit declaration of built-in function =E2=80=98strlen=E2=80=99 [-Wbuiltin-declar= ation-mismatch] 185 | fail (msg, strlen (msg), "stack smashing detected: terminated"); | ^~~~~~ ../../../gcc/libssp/ssp.c:185:14: note: include =E2=80=98=E2=80= =99 or provide a declaration of =E2=80=98strlen=E2=80=99 ../../../gcc/libssp/ssp.c: In function =E2=80=98__chk_fail=E2=80=99: ../../../gcc/libssp/ssp.c:192:14: warning: incompatible implicit declaration of built-in function =E2=80=98strlen=E2=80=99 [-Wbuiltin-declar= ation-mismatch] 192 | fail (msg, strlen (msg), "buffer overflow detected: terminated"); | ^~~~~~ ../../../gcc/libssp/ssp.c:192:14: note: include =E2=80=98=E2=80= =99 or provide a declaration of =E2=80=98strlen=E2=80=99 make[3]: *** [Makefile:576: ssp.lo] Error 1 make[3]: Leaving directory '${gccobj}/amdgcn-amdhsa/libssp' make[2]: *** [Makefile:441: all] Error 2 make[2]: Leaving directory '${gccobj}/amdgcn-amdhsa/libssp' make[1]: *** [Makefile:13103: all-target-libssp] Error 2 make[1]: Leaving directory '${gccobj}' make: *** [Makefile:1013: all] Error 2 Is there some dependency I could be missing?