GUN make 版本差异记录

GUN make 版本差异记录

在解bug时(人生处处是bug),发现make版本差异问题,特此记录。

今天,蓝牙调试过程中出现crash问题,作为机动人员(打杂人员),此问题当仁不让的归我了。开始时猜测是最近的改动引入的。然后开始回退commit,经测试问题解决。本来是个很简单的问题,但是出于小心,加上也不明白那个小的改动为啥引入了这么大的问题。我就在这个改动基础上,多回退了几个版本,发现每个版本都是好的,即使加入了改动,也没有造成crash。于是,我使用了最新的代码,分别加入之前的改动和不做更改,两个进行比较。发现两版本都没有引入crash问题。

由此引入了新的问题,我编译的bin文件与发版本的bin文件不一致。通过winhex比较发现,两bin文件确实差异较大。这才把目光转到编译器上面,猜想是gcc或者make版本差异导致。经排除最终确定是GUN make版本差异问题。

查阅资料后,发现问题太大,不是问题严重,是搞懂版本差异较为困难。国内网站也不给力,除了找到些文献资料,一点相关的记录都没。Google搜索发现,有一老哥遇到相似问题。

问题描述:

I am building an Embedded ARM project using gcc with C++:

11:01:29 ○⨠ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 224288]
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is  NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and make:

17:11:17 ○⨠ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

I was building a recent piece of code and it just wasn’t working for me at all - the code built and deployed fine but the functionality just wasn’t there. Tt made no sense as the code looked entirely fine.

A colleague reviewed it with me and we could find no problem with the code so for a laugh, we decided to get him to build and deploy it.

It worked fine!

So inspecting our versions, he was running make 4.1. I upgraded to this and hey presto, it worked fine.

11:06:15 ○⨠ make --version
GNU Make 4.1
Built for x86_64-apple-darwin14.3.0
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

We played some more with 3.81 and deduced that optimisation may have been the problem.

But both instances were passing -Os to gcc.

So, my question is this - why would Make have an influence on the compiler here?!

老哥回答:

1、make itself really has very, very little idea about -Os, GCC and optimization flags. Makefiles are rules to call external programs with specific arguments, and make executes those rules. The knowledge about -Os is in one of those rules.

2、You should compare the commands executed when you run the Makefile in Make 3.8.1 compared with when you run it in Make 4.1. All Make does is run commands as specified by the Makefile. Also, how did you deduce that optimisation could be the problem?

3、In ver 3.8.2 Gnu make, variable 'HOSTCC' is not overridden in sub:recipe, even if it was specified in the command line.( I noticed this phenomenon when building u-boot. For more infomation about 'Makefile remade', see make manual '3.5 How Makefiles Are Remade'.)This difference seems to come from ver 3.8.2 gnu make's main.c(line 2091).

看了一下,和我的问题相关性不大。

然后找啊找,找到一个神奇的网站,先记录下。

Amazing 自取–>’ https://fossies.org/diffs/all.html#P ’

网站上记录了很多软件版本升级的更改。宝藏网站,强烈建议收藏!!!

虽说make版本差异以及没能直观看到,上述资料还是能解决大部分问题的。另GUN make手册附上。

链接:https://pan.baidu.com/s/1ly8Q6DmHqk4LG2QWQ81eLA 
提取码:5j44

猜你喜欢

转载自blog.csdn.net/weixin_42762173/article/details/121775145
今日推荐