德尔福编译和构建产生对同一项目的不同的二进制 [英] Delphi Compile and Build produce different binary on same project

查看:127
本文介绍了德尔福编译和构建产生对同一项目的不同的二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个新的VCL应用程序的编译构建操作产生相同的二进制文件和地图文件(与.exe文件的末尾细微差别,即使包括版本信息在项目选项关闭 - 已经讨论过)。地图文件是字节相同的字节。但文我添加任何第三方组件的二进制文件和地图(!)文件生成产生和编译是显著不同!

In a fresh VCL application Compile and Build operation produce the same binary and map file (with minor differences at the end of .exe file even if "include version information in project" option is switched off - already discussed). Map file is the same byte to byte. But wen I add any third-party component the binary and map(!) file produced by Build and Compile are significantly different!

测试德尔福的两个版本:结果
  - 7.0版(8.1编译)结果
  - codeGear™的RAD Studio 2007版本11.0.2902.10471(+ 2007年12月更新)

Tested on two versions of Delphi:
- Version 7.0 (Build 8.1)
- CodeGear™ RAD Studio 2007 Version 11.0.2902.10471 (+December 2007 Update)

步骤重现:


  1. 创建新的VCL应用。可能是添加任何德尔福原生成分(我试着从斯坦达特,另外,Win32和系统标签的所有组件)。

  2. 打开工程选项的链接选项卡上的详细地图文件。

  3. 构建项目

  4. 重命名输出.exe和.MAP文件(例如:PROJECT1.EXE到project1b.exe和project1.map到project1b.map)。

  5. 编译项目

  6. 重命名输出.exe和.MAP文件(例如:PROJECT1.EXE到project1c.exe和project1.map到project1c.map)。

  7. 从第4和第6。比较文件(我用的WinMerge
    2.12.4.0)。

我们有一点不同的.exe文件,并完全一致.MAP文件。那么,如果我们再次重复所有步骤,但在项目的第三方组件使用(我尝试ODAC,DOA,DevEx preSS和自制的),我们获得更多不同的.exe和不同.MAP文件。

We have little different .exe files and fully identical .map files. Then if we repeat all steps again but use in the project third-party component (I try ODAC, DOA, DevExpress and selfmade) we get more different .exe and different .map files.

为什么呢?有什么建议?

Why? Any suggestions?

更新结果
我是如何发现这一点,它为什么吸引我的一些信息:结果
项目是从的MSBuild简单的脚本建立。当在项目中加入翻译直通ITE(与资源DLL),我发现,当项目是生成(从脚本或IDE) - 翻译版本的工作错误 - 按钮一些文本,标签等,得到了错误的地方(从字面上另一按钮,标签)。当项目从IDE编译 - 一切正常。于是,我开始比较生成和编译输出...

UPDATE
Some information about how I found this and why it's interests me:
Project is build from simple script with MSBuild. When in the project was added translation thru ITE (dll with resources) I found that when project was Build (from script or from IDE) - translated version work wrong - some text on button, labels etc. got from wrong place (literally from another button, labels). When project Compiled from IDE - everything is ok. So I start compare Build and Compile output...

推荐答案

你看到的简直就是编译器的内置化妆逻辑的产物。当你做一个构建,它告诉编译器来构建所有可用的资源。因此,德尔福处理每一个源文件,并在用途列出它认为源中的每个单元,它就会建立该文件。为此,它会递归。当你做了编译,只有现有的.dcu文件被加载,如果他们发现了最新的,什么都不做。这实际上可以导致在该单元,因为每个.dcu将有效压扁用途列表发现了不同的顺序。由于单元被发现并以不同的顺序装入,它们在转,以不同的顺序相连。这就是为什么你的地图文件看起来如此不同。由于同一消息来源,地图文件应该是,如果你做的两个版本在一排排或两编译相同的。

What you're seeing is simply an artifact of the built-in make logic of the compiler. When you do a build, it tells the compiler to build all available sources. So Delphi processes each source file and for each unit in the uses lists for which it finds source, it will then build that file. It does this recursively. When you do a compile, only the existing .dcu files are loaded and if they're found to be up-to-date, nothing is done. This can actually lead to a different order in which the units are discovered since each .dcu will effectively "flatten" the uses list. Since the units are discovered and loaded in a different order, they are in-turn, linked in a different order. This is why your map files look so different. Given the same sources, the map file should be the same if you do two builds in a row or two compiles in a row.

差价其他原因是更多的平凡而包括像PE头时间戳和填充其他位和路线。

Other causes for differences are more mundane and include things like the PE header time stamp, and other bits of padding and alignments.

这篇关于德尔福编译和构建产生对同一项目的不同的二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆