0

我有一个在我的默认 shell 下运行的二进制文件。

二进制运行得很好:

./binary input.dat

但是,如果我把它放在一个 make 文件中:

 SHELL=/bin/bash

 runos:
      ./binary input.dat

代码崩溃了,让我很无助。这是我到目前为止测试的内容,我的 Make 文件和 shell 中的所有内容:

  1. ulimit -a: 完全相同的。
  2. 如上所示,将 shell 设置为 bash。
  3. SHELL 和 Make 中环境变量的差异:

    env | sort > vars.1

    内部制作

    env | sort > vars.2

    然后使用以下命令在 Make 中运行带有额外变量的二进制文件:

    env SHLVL=2 MAKELEVEL=1 MAKEFLAGS= ./binary input.dat

  4. strace 在外壳和内部制作:

    strace -o debug binary input.dat

代码在 Make 中不断崩溃,并在 shell 中运行。我已经在考虑为我的测试用例转储 Make 并只编写 shell 脚本。但我很想知道有什么区别。

Fortran 代码(F77、F90 和 F95 的混合)是使用 gfortran-4.4 和以下选项编译的:

FFLAGS= -g -fbacktrace

所以,具体的问题是,我能做些什么来让这个二进制文件在 Debian 的 make 下运行!?

更新:

我刚刚在 CentOS 机器(v5.8)上再次测试,Makefile 中的代码不会崩溃(GNU Make 版本 3.81)。我还在我的 Debian Wheezy 和 openSUSE 11.4 上进行了测试,两者都使用 GNU Make 版本 3.82 - 它崩溃了!我使用 GNU Make 版本 3.81 在 Debian Squeeze 上进行了测试,但它确实崩溃了。所以,我认为它不依赖于 GNU Make 版本。

崩溃时的错误:

 enter timeloop
 ------------------------------------------------------------------------
 timestep:     1  time: 2.500E-02 days         delt: 2.500E-02 days        
 -------------------------------------------
    terminated in routine react_snia      
    maximum number of iterations exceeded   
    bye now ...                             
 -------------------------------------------
failure in timeloop
no further time step reduction possible
try reducing min. time step, bye now ...

尝试使用“waf”解决“GNU Make”

我想测试waf已经有一段时间了,所以这里有另一个有趣的观察:我写了一个wscript包含一个函数的函数:

import os

def run(ctx):
    os.system('./binary input.dat')

waf run跑!

如果我将run方法更改为:

import subprocess as sp
def run(ctx):
    sp.call('./binary input.dat', shell=True)

该二进制文件也可以按预期工作。

所以,现在我正在考虑GNU Make以一种可能导致二进制文件失败的方式分叉一个新的子外壳(尽管在 RHEL 5.8 下 Make 确实有效)。

4

1 回答 1

0

解决方案:从源代码编译make ...

阅读以了解更多信息。

好的,所以在非常绝望之后,我做了我应该做的事,然后才把make所有的麻烦都归咎于我。
我认为问题是Debian特有的。但我猜 CentOS-5.8 中的版本是一个补丁版本,虽然它说它是 v.3.81。
因此,对于那些想知道我的解决方案的人来说:

wget http://ftp.gnu.org/gnu/make/make-3.82.tar.gz
tar xvzf make-3.82.tar.gz
cd make-3.82
./configure
./build.sh
 # copy make to the directory with the binary and input and run the local make version
./make
# everything works as expected !!!

我想让我们缩小范围-

wget http://ftp.gnu.org/gnu/make/make-3.80.tar.gz
tar xvzf make-3.80.tar.gz
cd make-3.80
./configure
./build.sh
 # copy make to the directory with the binary and input and run the local make version
./make
# everything works as expected !!!

是 3.81 版本吗?

wget http://ftp.gnu.org/gnu/make/make-3.81.tar.gz
tar xvzf make-3.81.tar.gz
cd make-3.81
./configure
./build.sh
 # copy make to the directory with the binary and input and run the local make version
./make
# FAIL! Like with the make version in Debian.

因此,我想我在 GNU Make v.3.81 中遇到了一些非常奇怪的错误。

于 2012-12-28T14:57:20.363 回答