在configure中找到底层编译器

发布于 2024-09-09 11:02:18 字数 677 浏览 1 评论 0原文

我有一个使用编译器包装器编译的应用程序,例如 h5fc/h5cc(HDF5 编译器包装器)或 mpif90/mpicc(MPI 编译器包装器)。这些只是包装器,可以使用 -show 参数来查看真正的底层编译器,例如,

$ h5fc -show
ifort -fPIC [...] -lz -lm
$ mpif90 -show
ifort [...] -lmpichf90 -lmpichf90 -lpmpich -lmpich -lopa -lpthread

在这两种情况下,底层编译器都是 ifort。现在我使用 configure.ac 生成配置脚本来设置 Makefile,并且我希望能够向编译器添加依赖于编译器的参数,但是这个需要在 configure.ac 中有代码来找出 h5fc/ccmpif90/cc 的底层编译器是什么。我想这一定是可能的,但我不知道该怎么做。有人有什么建议吗?

额外问题:事实上,在某些情况下,我需要使用 h5pfc/cc 进行编译,它是启用 MPI 的 HDF5 包装器:

$ h5pfc -show
mpif90 [...] -lsz -lz -lm

这将需要迭代搜索,因为我需要执行 mpif90 -显示...

I have an application which is compiled using compiler wrappers such as h5fc/h5cc (the HDF5 compiler wrappers), or mpif90/mpicc (the MPI compiler wrappers). These are just wrappers, and it is possible using the -show argument to see the real underlying compiler, e.g.

$ h5fc -show
ifort -fPIC [...] -lz -lm
$ mpif90 -show
ifort [...] -lmpichf90 -lmpichf90 -lpmpich -lmpich -lopa -lpthread

In both cases the underlying compiler is ifort. Now I am using configure.ac to generate a configure script to set up the Makefile, and I want to be able to add compiler-dependent arguments to the compiler, but this requires having code in configure.ac to find out what the underlying compiler of h5fc/cc or mpif90/cc is. I imagine this must be possible, but I have no idea how to do this. Does anyone have any suggestions?

Bonus question: in fact in some cases I need to compile with h5pfc/cc which is the MPI-enabled HDF5 wrapper:

$ h5pfc -show
mpif90 [...] -lsz -lz -lm

which would require an iterative search, because I then need to do mpif90 -show...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2024-09-16 11:02:19

我终于想通了 - 答案很简单:

fccompiler = `h5fc -show | awk {'print $1'}`
AC_MSG_RESULT($fccompiler) # print out to check

I finally figured it out - the answer is simply to do:

fccompiler = `h5fc -show | awk {'print $1'}`
AC_MSG_RESULT($fccompiler) # print out to check
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文