[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

Ricardo Jesus via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 6 08:16:49 PST 2023


rj-jesus wrote:

Chipping into the discussion, since this patch I can also no longer build OpenBLAS or PETSc. OpenBLAS for example fails with
```
$ clang -v -O3 -mcpu=native  -DHAVE_C11 -Wall -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=72 -DMAX_PARALLEL_NUMBER=1 -DMAX_STACK_ALLOC=2048 -DNO_AFFINITY -DVERSION="\"0.3.25\"" -DBUILD_SINGLE -DBUILD_DOUBLE -DBUILD_COMPLEX -DBUILD_COMPLEX16  utest/CMakeFiles/openblas_utest.dir/utest_main.c.o utest/CMakeFiles/openblas_utest.dir/test_min.c.o utest/CMakeFiles/openblas_utest.dir/test_amax.c.o utest/CMakeFiles/openblas_utest.dir/test_ismin.c.o utest/CMakeFiles/openblas_utest.dir/test_rotmg.c.o utest/CMakeFiles/openblas_utest.dir/test_rot.c.o utest/CMakeFiles/openblas_utest.dir/test_axpy.c.o utest/CMakeFiles/openblas_utest.dir/test_dsdot.c.o utest/CMakeFiles/openblas_utest.dir/test_dnrm2.c.o utest/CMakeFiles/openblas_utest.dir/test_swap.c.o utest/CMakeFiles/openblas_utest.dir/test_dotu.c.o utest/CMakeFiles/openblas_utest.dir/test_potrs.c.o utest/CMakeFiles/openblas_utest.dir/test_kernel_regress.c.o -o utest/openblas_utest  -Wl,-rpath,/.../openblas/build/lib  lib/libopenblas.so.0.3  -lm
clang version 18.0.0 (git at github.com:llvm/llvm-project.git 17feb330aab39c6c0c21ee9b02efb484dfb2261e)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /.../llvm/trunk/bin
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/aarch64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda, version 
 "/usr/bin/ld" -EL -z relro --hash-style=gnu --eh-frame-hdr -m aarch64linux -pie -dynamic-linker /lib/ld-linux-aarch64.so.1 -o utest/openblas_utest /lib/aarch64-linux-gnu/Scrt1.o /lib/aarch64-linux-gnu/crti.o /usr/lib/gcc/aarch64-linux-gnu/12/crtbeginS.o -L/.../llvm/trunk/lib/clang/18/lib/aarch64-unknown-linux-gnu -L/usr/lib/gcc/aarch64-linux-gnu/12 -L/lib/aarch64-linux-gnu -L/usr/lib/aarch64-linux-gnu -L/lib -L/usr/lib -L/.../llvm/trunk/lib utest/CMakeFiles/openblas_utest.dir/utest_main.c.o utest/CMakeFiles/openblas_utest.dir/test_min.c.o utest/CMakeFiles/openblas_utest.dir/test_amax.c.o utest/CMakeFiles/openblas_utest.dir/test_ismin.c.o utest/CMakeFiles/openblas_utest.dir/test_rotmg.c.o utest/CMakeFiles/openblas_utest.dir/test_rot.c.o utest/CMakeFiles/openblas_utest.dir/test_axpy.c.o utest/CMakeFiles/openblas_utest.dir/test_dsdot.c.o utest/CMakeFiles/openblas_utest.dir/test_dnrm2.c.o utest/CMakeFiles/openblas_utest.dir/test_swap.c.o utest/CMakeFiles/openblas_utest.dir/test_dotu.c.o utest/CMakeFiles/openblas_utest.dir/test_potrs.c.o utest/CMakeFiles/openblas_utest.dir/test_kernel_regress.c.o -rpath /.../openblas/build/lib lib/libopenblas.so.0.3 -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/aarch64-linux-gnu/12/crtendS.o /lib/aarch64-linux-gnu/crtn.o
/usr/bin/ld: lib/libopenblas.so.0.3: undefined reference to `_QQEnvironmentDefaults'
/usr/bin/ld: lib/libopenblas.so.0.3: undefined reference to `_QQmain'
```

https://github.com/llvm/llvm-project/pull/73124


More information about the cfe-commits mailing list