Skip to content

Conversation

@LKedward
Copy link
Member

@LKedward LKedward commented Apr 9, 2021

  • Minimal set of changes to invoke a separate C compiler instead of passing C code to the Fortran compiler
  • Allows compiling packages with C code using Intel compiler collection, Fixes Cannot Compile C code with Intel #426
  • C compiler is chosen automatically based on the Fortran compiler selection
    • Companion compiler chosen if known, otherwise fall-back to invoking the Fortran compiler for C as done currently
    • C compiler can alternatively be specified explicitly using environment variable FPM_C_COMPILER
Compiler ID FC CC
gcc gfortran gcc
intel_classic ifort icc
intel_llvm ifx icx
intel_flang flang clang
ibmxl xlf xlc

Not addressed in this PR: specifying C compiler flags

@LKedward LKedward marked this pull request as ready for review April 11, 2021 10:08
Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍.

I wonder if we should aim towards making build_target a method of a more abstract compiler or linker object to separate the vendor/platform specific build logic from our targets in the long-term. This could be useful for the ar vs link issue as well.

@LKedward
Copy link
Member Author

Good point, I agree. That seems like a natural direction to take with the targets in the future.

@ivan-pi
Copy link
Member

ivan-pi commented Apr 11, 2021

The Rust cc crate converged to having separate Build (a builder for compilation of a native library) and Tool (configuration used to represent an invocation of a C compiler) abstractions. Their is of course the important difference that fpm is more like cargo and the cc crate all in one, so there is perhaps more potential to share information across layers.

Copy link
Member

@everythingfunctional everythingfunctional left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this do something about flags when compiling C code? I'm fine if we want to add that as a separate PR, just curious.

Also, my installation of oneAPI on Windows doesn't seem to have icc. It works as expected for everything else I tried, (gfortran, ifort, and ifx on Windows, Mac and Linux).

Otherwise, I think this looks good.

@LKedward
Copy link
Member Author

Should this do something about flags when compiling C code? I'm fine if we want to add that as a separate PR, just curious.

I thought that best left for a separate PR, since it will require some discussion about best approaches.

@LKedward
Copy link
Member Author

Thanks for the reviews. I'll merge later today if there are no further comments.

@LKedward LKedward merged commit fbbfb2c into fortran-lang:master Apr 17, 2021
@LKedward LKedward deleted the intel-c branch April 17, 2021 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot Compile C code with Intel

4 participants