oneapi-src / oneapi-src/oneAPI-samples

Cannot Build 32 Bit Hello World Using CMake

Abierto
#2,312 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug
Lenguaje dominante
C++
Estrellas
1.2k
Forks
745
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Summary

In short when i try to build a application using CMake right after running source /opt/intel/oneapi/setvars.sh ia32 it does not work. I created a dockerfile to summarize my findings. It simply installs the oneAPI toolchain on a empty ubuntu base image and tries to compile a sample application. If this is a incorrect pattern for building let me know. I was following the documentation

Enable CMake with setvars.sh, oneapi-vars.sh, or vars.sh
If you are already using setvars.sh, oneapi-vars.sh, or vars.sh to initialize the build environment, then all the necessary environment variables are being set and you should be able to use CMake. For more information on these scripts, see Use the setvars and oneapi-vars Scripts with Linux*.

# Use nomral ubuntu base
FROM public.ecr.aws/ubuntu/ubuntu:22.04

# enable using "source" in docker
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# install dev tools
RUN apt-get update && \
    apt-get install -y cmake golang-go wget git

# install intel compiler
RUN wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/fdc7a2bc-b7a8-47eb-8876-de6201297144/l_BaseKit_p_2024.1.0.596.sh && \
    chmod +x ./l_BaseKit_p_2024.1.0.596.sh && \
    ./l_BaseKit_p_2024.1.0.596.sh -a --silent --eula accept &&\
    chmod +x /opt/intel/oneapi/setvars.sh

# create helloworld
RUN mkdir hello-world && \
    cd hello-world && \
    touch CMakeLists.txt && \
    echo "cmake_minimum_required(VERSION 3.22)" >> CMakeLists.txt && \
    echo "project(hello_world)" >> CMakeLists.txt && \
    echo "set(CMAKE_CXX_STANDARD 20)" >> CMakeLists.txt && \
    echo "add_executable(hello_world main.cpp)" >> CMakeLists.txt && \
    touch main.cpp && \
    echo "#include<iostream>" >> main.cpp &&\
    echo "" >> main.cpp &&\
    echo "auto main() -> int {" >> main.cpp &&\
    echo -e "    std::cout << \"Hello World\";" >> main.cpp &&\
    echo "    return 0;" >> main.cpp &&\
    echo "}" >> main.cpp

# build basic application
RUN source /opt/intel/oneapi/setvars.sh ia32 &&\
    cd hello-world && \
    mkdir build && \
    cd build && \
    cmake  -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx .. && \
    cmake --build .

this will result in the error

CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/opt/intel/oneapi/compiler/2024.1/bin/icx"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /hello-world/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_84458/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_84458.dir/build.make CMakeFiles/cmTC_84458.dir/build
    gmake[1]: Entering directory '/hello-world/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_84458.dir/testCCompiler.c.o
    /opt/intel/oneapi/compiler/2024.1/bin/icx    -MD -MT CMakeFiles/cmTC_84458.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_84458.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_84458.dir/testCCompiler.c.o -c /hello-world/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_84458
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_84458.dir/link.txt --verbose=1
    /opt/intel/oneapi/compiler/2024.1/bin/icx CMakeFiles/cmTC_84458.dir/testCCompiler.c.o -o cmTC_84458
    /usr/bin/ld: cannot find Scrt1.o: No such file or directory
    /usr/bin/ld: cannot find crti.o: No such file or directory
    /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.so when searching for -lm
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.a when searching for -lm
    /usr/bin/ld: cannot find -lm: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.so when searching for -lm
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: cannot find -lgcc_s: No such file or directory
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: cannot find -lgcc_s: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so when searching for -lc
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.a when searching for -lc
    /usr/bin/ld: cannot find -lc: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so when searching for -lc
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: cannot find -lgcc_s: No such file or directory
    /usr/bin/ld: cannot find crtendS.o: No such file or directory
    /usr/bin/ld: cannot find crtn.o: No such file or directory
    icx: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [CMakeFiles/cmTC_84458.dir/build.make:100: cmTC_84458] Error 1
    gmake[1]: Leaving directory '/hello-world/build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_84458/fast] Error 2

however if i replace source /opt/intel/oneapi/setvars.sh ia32 with source /opt/intel/oneapi/setvars.sh it will compile as expected and use the correct compiler.

Version

2024.1.0.596

Environment

Ubuntu 22.04

also full environment can be detailed in the dockerfile.

Steps to reproduce

given the dockerfile is present in your dir you can simply run docker build . to attempt to build it.

Observed behavior

Saw the error

CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/opt/intel/oneapi/compiler/2024.1/bin/icx"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /hello-world/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_84458/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_84458.dir/build.make CMakeFiles/cmTC_84458.dir/build
    gmake[1]: Entering directory '/hello-world/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_84458.dir/testCCompiler.c.o
    /opt/intel/oneapi/compiler/2024.1/bin/icx    -MD -MT CMakeFiles/cmTC_84458.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_84458.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_84458.dir/testCCompiler.c.o -c /hello-world/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_84458
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_84458.dir/link.txt --verbose=1
    /opt/intel/oneapi/compiler/2024.1/bin/icx CMakeFiles/cmTC_84458.dir/testCCompiler.c.o -o cmTC_84458
    /usr/bin/ld: cannot find Scrt1.o: No such file or directory
    /usr/bin/ld: cannot find crti.o: No such file or directory
    /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.so when searching for -lm
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.a when searching for -lm
    /usr/bin/ld: cannot find -lm: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.so when searching for -lm
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: cannot find -lgcc_s: No such file or directory
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: cannot find -lgcc_s: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so when searching for -lc
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.a when searching for -lc
    /usr/bin/ld: cannot find -lc: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so when searching for -lc
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: cannot find -lgcc_s: No such file or directory
    /usr/bin/ld: cannot find crtendS.o: No such file or directory
    /usr/bin/ld: cannot find crtn.o: No such file or directory
    icx: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [CMakeFiles/cmTC_84458.dir/build.make:100: cmTC_84458] Error 1
    gmake[1]: Leaving directory '/hello-world/build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_84458/fast] Error 2

I do believe this is related to setvars.sh not using the correct linker/glibc when ia32 is set.

Expected behavior

Dockerfile builds using ia32 as a arugment to setvars.sh

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza ejecutando docker build . con el Dockerfile indicado e inspecciona los CMakeLists.txt, main.cpp y la salida de compiler-test generados después de hacer source de /opt/intel/oneapi/setvars.sh ia32. Compara esa ruta de compilación con la compilación exitosa usando setvars.sh sin ia32; se considera terminado cuando el Dockerfile compila correctamente el ejemplo con el argumento ia32.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cmake, cpp, docker, ubuntu
Área
build-system, compilers, devops, operating-systems
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.