Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support of icx/icpx and dpcpp toolchain #2474

Closed
jonathanpoelen opened this issue Jun 19, 2022 · 18 comments
Closed

support of icx/icpx and dpcpp toolchain #2474

jonathanpoelen opened this issue Jun 19, 2022 · 18 comments

Comments

@jonathanpoelen
Copy link
Contributor

Is your feature request related to a problem? Please describe.

xmake should be able to use icx, icpx, dpcpp and dpcpp-cl who are intel llvm compiler.

Describe the solution you'd like

xmake f --toolchain=icx and xmake f --toolchain=dpcpp should work.

icx is a C compiler, others are C++ compiler.

dpcpp-cl is like clang-cl, others are like clang.

I don't know to what extent -E is used, but you should know that dpcpp (and dpcpp-cl?) has a problem with the -E flag: it expects a syntactically valid file, as if it were compiling.

$ cat a.cpp
__clang_major__
$ dpcpp a.cpp
a.cpp:1:1: error: expected unqualified-id
__clang_major__
^
<built-in>:404:25: note: expanded from here
#define __clang_major__ 14
                        ^
1 error generated.
$ cat b.cpp
int x = __clang_major__;
$ dpcpp b.cpp
[...]
int x = 14;
[...]
no error

Reading the file from stdin doesn't work either (it seems to want to read the stream twice)

$ dpcpp -x c++ - <<<'__clang_major__'
same errors as above
$ dpcpp -x c++ - <<<'int x = __clang_major__;'
append-file: input file not found

Describe alternatives you've considered

xmake f --toolchain=clang --cxx=icpx --cc=icx, but it doesn't work

error: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:56: cannot find known tool script for icpx
stack traceback:
	@programdir/core/base/utils.lua:290: in function <@programdir/core/base/utils.lua:280>
	[C]: in function 'error'
	@programdir/core/base/os.lua:872: in function 'os.raiselevel'
	(...tail calls...)
	...mdir/core/sandbox/modules/import/core/base/scheduler.lua:56: in field 'co_start_withopt'
	@programdir/modules/private/async/runjobs.lua:217: in function <@programdir/modules/private/async/runjobs.lua:162>
	[C]: in function 'xpcall'
	@programdir/core/base/utils.lua:280: in function 'sandbox/modules/utils.trycall'
	@programdir/core/base/scheduler.lua:504: in function 'base/scheduler.co_group_begin'
	...mdir/core/sandbox/modules/import/core/base/scheduler.lua:94: in field 'co_group_begin'
	@programdir/modules/private/async/runjobs.lua:162: in function <@programdir/modules/private/async/runjobs.lua:56>
	(...tail calls...)
	@programdir/actions/build/build.lua:252: in function <@programdir/actions/build/build.lua:240>
	(...tail calls...)
	@programdir/actions/build/main.lua:103: in global '_do_build'
	@programdir/actions/build/main.lua:150: in function <@programdir/actions/build/main.lua:144>
	[C]: in function 'xpcall'
	@programdir/core/base/utils.lua:280: in function 'sandbox/modules/utils.trycall'
	@programdir/core/sandbox/modules/try.lua:121: in global 'try'
	@programdir/actions/build/main.lua:142: in function <@programdir/actions/build/main.lua:108>
	(...tail calls...)
	[C]: in function 'xpcall'
	@programdir/core/base/utils.lua:280: in function 'sandbox/modules/utils.trycall'
	(...tail calls...)
	@programdir/core/base/task.lua:519: in function 'base/task.run'
	@programdir/core/main.lua:278: in upvalue 'cotask'
	@programdir/core/base/scheduler.lua:388: in function <@programdir/core/base/scheduler.lua:385>

Additional context

No response

@waruqi
Copy link
Member

waruqi commented Jun 19, 2022

try xmake f --toolchain=icc

@jonathanpoelen
Copy link
Contributor Author

icc/icpc are another compilers not based on llvm. Also, forcing paths doesn't work

$ xmake f --toolchain=icc --cxx=icpc --cc=icc && xmake -vD
checking for platform ... linux
checking for architecture ... x86_64
checking for Intel C/C++ Compiler (x86_64) ... ok
checking for icpc ... /home/jonathan/bin/icpc
checking for flags (-fPIC) ... ok
> icpc "-fPIC"
checking for icpc ... /opt/intel/oneapi/compiler/latest/linux/bin/intel64/icpc
checking for the linker (ld) ... icpc
checking for /opt/intel/oneapi/compiler/latest/linux/bin/intel64/icpc ... ok
checking for flags (-fPIC) ... no
> icpc "-fPIC"
checkinfo: @programdir/core/sandbox/modules/os.lua:257: ld: cannot find -limf: No such file or directory
ld: cannot find -lsvml: No such file or directory
ld: cannot find -lirng: No such file or directory

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:872]:
    [@programdir/core/sandbox/modules/os.lua:257]: in function 'runv'
    [@programdir/modules/detect/tools/gcc/has_flags.lua:42]:
[ 50%]: linking.release test
/opt/intel/oneapi/compiler/latest/linux/bin/intel64/icpc -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/test.cpp.o -m64

icc/icpc or /home/jonathan/bin/icc//home/jonathan/bin/icpc should be used here. Who in are wrappers that add -shared-intel -L /opt/intel/oneapi/compiler/2022.1.0/linux/compiler/lib/intel64_lin/. Doing it at --ldflags= does not remove all errors, but compiles.

@waruqi
Copy link
Member

waruqi commented Jun 19, 2022

try xmake f --toolchain=icc --cc=/home/jonathan/bin/icc --cxx=/home/jonathan/bin/icpc -c

@jonathanpoelen
Copy link
Contributor Author

Still the same error. The wrong icpc is being used.

@waruqi
Copy link
Member

waruqi commented Jun 20, 2022

please run

xmake f --toolchain=icc --cc=/home/jonathan/bin/icc --cxx=/home/jonathan/bin/icpc -cvD
xmake -rvD

and give me full logs.

@jonathanpoelen
Copy link
Contributor Author

checking for platform ... linux
checking for architecture ... x86_64
checking for icc ... /opt/intel/oneapi/compiler/latest/linux/bin/intel64/icc
checking for Intel C/C++ Compiler (x86_64) ... ok
configure
{
    buildir = build
    toolchain = icc
    cc = /home/jonathan/bin/icc
    plat = linux
    mode = release
    cxx = /home/jonathan/bin/icpc
    clean = true
    ccache = true
    ndk_stdcxx = true
    kind = static
    arch = x86_64
    host = linux
}
checking for /home/jonathan/bin/icpc ... ok
checking for flags (-fPIC) ... ok
> icpc "-fPIC"
[ 25%]: ccache compiling.release test.cpp
/home/jonathan/bin/icpc -c -m64 -o build/.objs/test/linux/x86_64/release/test.cpp.o test.cpp
checking for flags (-MMD -MF) ... ok
> icpc "-MMD" "-MF" "/dev/null"
checking for icpc ... /opt/intel/oneapi/compiler/latest/linux/bin/intel64/icpc
checking for the linker (ld) ... icpc
checking for /opt/intel/oneapi/compiler/latest/linux/bin/intel64/icpc ... ok
checking for flags (-fPIC) ... no
> icpc "-fPIC"
checkinfo: @programdir/core/sandbox/modules/os.lua:257: ld: cannot find -limf: No such file or directory
ld: cannot find -lsvml: No such file or directory
ld: cannot find -lirng: No such file or directory

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:872]:
    [@programdir/core/sandbox/modules/os.lua:257]: in function 'runv'
    [@programdir/modules/detect/tools/gcc/has_flags.lua:42]:
[ 50%]: linking.release test
/opt/intel/oneapi/compiler/latest/linux/bin/intel64/icpc -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/test.cpp.o -m64
error: @programdir/modules/private/async/runjobs.lua:256: @programdir/actions/build/kinds/binary.lua:74: @programdir/core/sandbox/modules/os.lua:257: ld: cannot find -limf: No such file or directory
ld: cannot find -lsvml: No such file or directory
ld: cannot find -lirng: No such file or directory

stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:872]:
    [@programdir/core/sandbox/modules/os.lua:257]: in function 'runv'
    [@programdir/modules/core/tools/gcc.lua:363]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:280]:
    [@programdir/actions/build/kinds/binary.lua:74]: in function 'callback'
    [@programdir/modules/core/project/depend.lua:189]: in function 'on_changed'
    [@programdir/actions/build/kinds/binary.lua:55]: in function '_do_link_target'
    [@programdir/actions/build/kinds/binary.lua:102]:
    [@programdir/actions/build/kinds/binary.lua:129]: in function '_link_target'
    [@programdir/actions/build/kinds/binary.lua:157]: in function 'jobfunc'
    [@programdir/modules/private/async/runjobs.lua:232]:
    [C]: in function 'xpcall'
    [@programdir/core/base/utils.lua:280]: in function 'trycall'
    [@programdir/core/sandbox/modules/try.lua:121]: in function 'try'
    [@programdir/modules/private/async/runjobs.lua:218]: in function 'cotask'
    [@programdir/core/base/scheduler.lua:388]:

stack traceback:
	[C]: in function 'error'
	@programdir/core/base/os.lua:872: in function 'base/os.raiselevel'
	(...tail calls...)
	@programdir/modules/private/async/runjobs.lua:256: in field 'catch'
	@programdir/core/sandbox/modules/try.lua:127: in global 'try'
	@programdir/modules/private/async/runjobs.lua:218: in upvalue 'cotask'
	@programdir/core/base/scheduler.lua:388: in function <@programdir/core/base/scheduler.lua:385>

@waruqi
Copy link
Member

waruqi commented Jun 20, 2022

you can update to dev and try it again. xmake update -s dev

@jonathanpoelen
Copy link
Contributor Author

Same, only difference is the line number of the stack trace

-    [@programdir/modules/core/tools/gcc.lua:363]:
+    [@programdir/modules/core/tools/gcc.lua:368]:

@waruqi
Copy link
Member

waruqi commented Jun 20, 2022

this patch 47d4445

@jonathanpoelen
Copy link
Contributor Author

This is what I have.

@waruqi
Copy link
Member

waruqi commented Jun 21, 2022

It should work, can you try

xmake f --toolchain=icc --cc=/home/jonathan/bin/icc --cxx=/home/jonathan/bin/icpc -cvD
xmake -rvD

and give me all output again?

@waruqi
Copy link
Member

waruqi commented Jun 21, 2022

/home/jonathan/bin/icpc -c -m64 -o build/.objs/test/linux/x86_64/release/test.cpp.o test.cpp

I saw your previous logs, it works! /home/jonathan/bin/icpc

/opt/intel/oneapi/compiler/latest/linux/bin/intel64/icpc -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/test.cpp.o -m64

but you just switch compiler to /home/jonathan/bin/icpc, do not switch linker to /home/jonathan/bin/icpc.

if you want to switch linker, you need set --ld=/home/jonathan/bin/icpc

xmake f --toolchain=icc --cc=/home/jonathan/bin/icc --cxx=/home/jonathan/bin/icpc --ld=/home/jonathan/bin/icpc -cvD
xmake -rvD

@jonathanpoelen
Copy link
Contributor Author

Oh... Quite simply.

Otherwise, for icx? It doesn't work specifying it as the compiler, either with toolset=icc (which is wrong) or toolset=clang. Same log in both cases:

$ xmake f --toolchain=clang --cc=/home/jonathan/bin/icx --cxx=/home/jonathan/bin/icpx --ld=/home/jonathan/bin/icpx -cvD
checking for platform ... linux
checking for architecture ... x86_64
checking for clang ... /usr/bin/clang
configure
{
    toolchain = clang
    cxx = /home/jonathan/bin/icpx
    mode = release
    ndk_stdcxx = true
    host = linux
    kind = static
    ld = /home/jonathan/bin/icpx
    plat = linux
    arch = x86_64
    clean = true
    ccache = true
    buildir = build
    cc = /home/jonathan/bin/icx
}
$ xmake -rvD    
error: @programdir/core/main.lua:280: @programdir/actions/build/main.lua:166: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:96: ...mdir/core/sandbox/modules/import/core/base/scheduler.lua:56: @programdir/modules/private/async/runjobs.lua:256: ...amdir/core/sandbox/modules/import/core/tool/compiler.lua:37: cannot find known tool script for /home/jonathan/bin/icpx
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:872]:
    [...amdir/core/sandbox/modules/import/core/tool/compiler.lua:37]: in function 'load'
    [@programdir/modules/private/action/build/object.lua:40]: in function 'script'
    [@programdir/modules/private/action/build/object.lua:98]: in function 'build_object'
    [@programdir/modules/private/action/build/object.lua:123]: in function 'jobfunc'
    [@programdir/modules/private/async/runjobs.lua:232]:

stack traceback:
	[C]: in function 'error'
	@programdir/core/base/os.lua:872: in function 'os.raiselevel'
	(...tail calls...)
	@programdir/modules/private/async/runjobs.lua:256: in field 'catch'
	@programdir/core/sandbox/modules/try.lua:127: in global 'try'
	@programdir/modules/private/async/runjobs.lua:218: in upvalue 'cotask'
	@programdir/core/base/scheduler.lua:388: in function <@programdir/core/base/scheduler.lua:385>
stack traceback:
	@programdir/core/base/utils.lua:290: in function <@programdir/core/base/utils.lua:280>
	[C]: in function 'error'
	@programdir/core/base/os.lua:872: in function 'os.raiselevel'
	(...tail calls...)
	...mdir/core/sandbox/modules/import/core/base/scheduler.lua:56: in field 'co_start_withopt'
	@programdir/modules/private/async/runjobs.lua:217: in function <@programdir/modules/private/async/runjobs.lua:162>
	[C]: in function 'xpcall'
	@programdir/core/base/utils.lua:280: in function 'base/utils.trycall'
	@programdir/core/base/scheduler.lua:504: in function 'base/scheduler.co_group_begin'
	...mdir/core/sandbox/modules/import/core/base/scheduler.lua:94: in field 'co_group_begin'
	@programdir/modules/private/async/runjobs.lua:162: in function <@programdir/modules/private/async/runjobs.lua:56>
	(...tail calls...)
	@programdir/actions/build/build.lua:252: in function <@programdir/actions/build/build.lua:240>
	(...tail calls...)
	@programdir/actions/build/main.lua:103: in global '_do_build'
	@programdir/actions/build/main.lua:150: in function <@programdir/actions/build/main.lua:144>
	[C]: in function 'xpcall'
	@programdir/core/base/utils.lua:280: in function 'base/utils.trycall'
	@programdir/core/sandbox/modules/try.lua:121: in global 'try'
	@programdir/actions/build/main.lua:142: in function <@programdir/actions/build/main.lua:108>
	(...tail calls...)
	[C]: in function 'xpcall'
	@programdir/core/base/utils.lua:280: in function 'base/utils.trycall'
	(...tail calls...)
	@programdir/core/base/task.lua:501: in function 'base/task.run'
	@programdir/core/main.lua:278: in upvalue 'cotask'
	@programdir/core/base/scheduler.lua:388: in function <@programdir/core/base/scheduler.lua:385>
stack traceback:
	[C]: in function 'error'
	@programdir/core/base/os.lua:872: in function 'os.raiselevel'
	(...tail calls...)
	@programdir/core/main.lua:280: in upvalue 'cotask'
	@programdir/core/base/scheduler.lua:388: in function <@programdir/core/base/scheduler.lua:385>

icc and icx are really 2 different compilers, for example:

test.cpp

template<auto T> struct A {};
struct B { using type = int; };

int main() {
  A<B{}>();
}
$ icpx -std=c++20 -fsanitize=address test.cpp
ok, compiles and asan is recognized
$ icpc -std=c++20 -fsanitize=address test.cpp
icpc: command line warning #10148: option '-fsanitize=address' not supported
test.cpp(5): error: a nontype template parameter may not have class type
    A<B{}>();
      ^

compilation aborted for test.cpp (code 2)

icx is clang/llvm + Intel proprietary optimizations and code generation.

@waruqi
Copy link
Member

waruqi commented Jun 22, 2022

Yes, only the icc and icpc compilers are currently supported, not the icx icpx compiler, which is unknown to xmake.

I don't have the icx icpx compiler environment to support them or test them at the moment. You can open pr to support them.

you can add tools/icpx.lua and tools/icx.lua, like this https://github.com/xmake-io/xmake/blob/master/xmake/modules/core/tools/icpc.lua

and add find_icx.lua and find_icpx.lua, like this https://github.com/xmake-io/xmake/blob/master/xmake/modules/detect/tools/find_icpc.lua

This was referenced Jun 27, 2022
@waruqi waruqi closed this as completed Jun 27, 2022
@waruqi waruqi added this to the v2.6.9 milestone Jun 27, 2022
@explocion
Copy link

It seems that for dpcpp toolchain, xmake will check for icxenv. However, dpcpp should be standalone.

@waruqi
Copy link
Member

waruqi commented Oct 28, 2022

It seems that for dpcpp toolchain, xmake will check for icxenv. However, dpcpp should be standalone.

It just use find_icxenv to find dpcpp,

icxenv = find_icxenv()

you can also improve it and open a pr.

@explocion
Copy link

I mean the dpcpp supported in xmake now refers to a part of Intel's oneapi framework. However, I refer to the dpcpp that is built as a standalone dpcpp-llvm compiler. I'm thinking of renaming the current dpcpp toolchain as oneapi and adding a dpcpp-llvm toolchain as a variant of current llvm toolchain.

@waruqi
Copy link
Member

waruqi commented Oct 28, 2022

oneapi contains many compilers , icc, icx, ifortran, dpcpp, and we should not rename dpcpp to oneapi. but you can add dpcpp-llvm as a separate toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants