fpm icon indicating copy to clipboard operation
fpm copied to clipboard

fpm project with C source; Intel compilers on Windows

Open ghost opened this issue 4 years ago • 3 comments

I was trying to build an fpm project with Intel compilers on Windows and was running into issue.

C:\Temp\test>fpm run --compiler ifort
 + mkdir build\dependencies
GNU ar (GNU Binutils) 2.36.1
Copyright (C) 2021 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
 + mkdir build\ifort_FA91F1929995A164\test
 + ifort -c test\check.f90 /warn:all /check:all /error-limit:1 /Od /Z7 /assume:byterecl /traceback /Qcoarray:single /module:build\ifort_FA91F1929995A164\test /Ibuild\ifort_FA91F1929995A164\test  -o build\ifort_FA91F1929995A164\test\test_check.f90.o
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000
Copyright (C) 1985-2021 Intel Corporation.  All rights reserved.

 + icc -c .\.\src\csource.c -o build\ifort_FA91F1929995A164\test\src_csource.c.o
'icc' is not recognized as an internal or external command, operable program or batch file.
 Command failed
ERROR STOP

C source is src/csource.c

int func(void) { return 0;}

I would add an special case

case(id_intel_classic_windows)
    c_compiler = 'icl'

to https://github.com/fortran-lang/fpm/blob/master/src/fpm_compiler.f90#L341 and create a PR. But it wouldn't solve it, because icl syntax for 'compile-only, do not link', is icl /c file.c /Fofile.obj and that requires a change in https://github.com/fortran-lang/fpm/blob/master/src/fpm_backend.f90#L243. My understanding is that I should not add compiler specific flags to fpm_backend.f90.

[1] icl syntax: https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-setup/using-the-command-line/using-compiler-options.html

ghost avatar Jun 03 '21 00:06 ghost

The project builds with fpm run --compiler ifx.

Here is the output:

C:\Temp\test>fpm run --compiler ifx
 + mkdir build\dependencies
GNU ar (GNU Binutils) 2.36.1
Copyright (C) 2021 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
 + mkdir build\ifx_38882BE0A4E5729B\test
 + ifx -c test\check.f90 /warn:all /check:all /error-limit:1 /Od /Z7 /assume:byterecl /Qcoarray:single /module:build\ifx_38882BE0A4E5729B\test /Ibuild\ifx_38882BE0A4E5729B\test  -o build\ifx_38882BE0A4E5729B\test\test_check.f90.o
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2021.2.0 Beta Build 20210317
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

test/check.f90: remark #5415: Feature not yet implemented: Some 'check' options temporarily disabled.
 + icx -c .\.\src\csource.c -o build\ifx_38882BE0A4E5729B\test\src_csource.c.o
Intel(R) oneAPI DPC++/C++ Compiler for applications running on Intel(R) 64, Version 2021.2.0 Build 20210317
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

 + ifx -c .\.\src\test.f90 /warn:all /check:all /error-limit:1 /Od /Z7 /assume:byterecl /Qcoarray:single /module:build\ifx_38882BE0A4E5729B\test /Ibuild\ifx_38882BE0A4E5729B\test  -o build\ifx_38882BE0A4E5729B\test\src_test.f90.o
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2021.2.0 Beta Build 20210317
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

././src/test.f90: remark #5415: Feature not yet implemented: Some 'check' options temporarily disabled.
 + ar -rs build\ifx_38882BE0A4E5729B\test\libtest.a build\ifx_38882BE0A4E5729B\test\src_csource.c.o build\ifx_38882BE0A4E5729B\test\src_test.f90.o
ar: creating build\ifx_38882BE0A4E5729B\test\libtest.a
 + ifx -c app\main.f90 /warn:all /check:all /error-limit:1 /Od /Z7 /assume:byterecl /Qcoarray:single /module:build\ifx_38882BE0A4E5729B\test /Ibuild\ifx_38882BE0A4E5729B\test  -o build\ifx_38882BE0A4E5729B\test\app_main.f90.o
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2021.2.0 Beta Build 20210317
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

app/main.f90: remark #5415: Feature not yet implemented: Some 'check' options temporarily disabled.
 + mkdir build\ifx_38882BE0A4E5729B\app\
 + ifx  /warn:all /check:all /error-limit:1 /Od /Z7 /assume:byterecl /Qcoarray:single /module:build\ifx_38882BE0A4E5729B\test /Ibuild\ifx_38882BE0A4E5729B\test  build\ifx_38882BE0A4E5729B\test\app_main.f90.o build\ifx_38882BE0A4E5729B\test\libtest.a -o build\ifx_38882BE0A4E5729B\app\test.exe
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2021.2.0 Beta Build 20210317
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.29.30037.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:build/ifx_38882BE0A4E5729B/app/test.exe
-debug
-pdb:build/ifx_38882BE0A4E5729B/app/test.pdb
-subsystem:console
build/ifx_38882BE0A4E5729B/test/app_main.f90.o
build/ifx_38882BE0A4E5729B/test/libtest.a
 + ifx  /warn:all /check:all /error-limit:1 /Od /Z7 /assume:byterecl /Qcoarray:single /module:build\ifx_38882BE0A4E5729B\test /Ibuild\ifx_38882BE0A4E5729B\test  build\ifx_38882BE0A4E5729B\test\test_check.f90.o build\ifx_38882BE0A4E5729B\test\libtest.a -o build\ifx_38882BE0A4E5729B\test\check.exe
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2021.2.0 Beta Build 20210317
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.29.30037.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:build/ifx_38882BE0A4E5729B/test/check.exe
-debug
-pdb:build/ifx_38882BE0A4E5729B/test/check.pdb
-subsystem:console
build/ifx_38882BE0A4E5729B/test/test_check.f90.o
build/ifx_38882BE0A4E5729B/test/libtest.a
 Hello, test!

I think it should use the llvm-ar binary from the Intel toolchain though.

ghost avatar Jun 03 '21 00:06 ghost

Thanks for reporting @brocolis - I believe #451 will make it much easier to directly address these kinds of Windows specific problems.

LKedward avatar Jun 03 '21 15:06 LKedward

I think we can now look into this issue, the compile command for C source is generated here:

https://github.com/fortran-lang/fpm/blob/5c908fc0157b9e3637a83dc532ab1bea4fd8b184/src/fpm_compiler.f90#L669-L670

Instead we should save the compile-but-not-link-C-source argument in the compiler object when constructing the object and just use it when assembling the compile command.

awvwgk avatar Sep 05 '21 18:09 awvwgk