Different assembly code generated when no change in code or compiler options
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Different assembly code generated when no change in code or compiler options
Hi,
I am facing a weird issue, I used MIPS cross compiler to build MIPS based libs and lib building was fine. The very next day I build MIPS based libs again without changing code/compiler/compiler options(No change in compilation environment or code) but the newly generated libs are different from the previous one. To debug the issue further I took objdump of old and new libs I can see only 1 difference and that is as below
Well, is it stated in the documentation that the compiler is deterministic, i.e. it always generates the same output from the same input?
So... unless the compiler specifically states that it is deterministic, the OP should just shrug his shoulders and accept it? IMHO, caprice should be expected in government policies, not in compilers. Am subscribing to this mostly because i find it intriguing and would like to be notified if csakthikumar ever finds the reason behind this.
Same code (no changes)
Same tools (no changes)
Same process/makefile (no changes)
Result EXACTLY the same.
I'd say for years, since the 70's, we either assemble, or compile. And once we had a release, we froze that code, along with the tools to build it and many, many times we verified that it generated exactly the same result. This used to be part of a submission process for one of my former employer's freeze process. We had to prove that we could regenerate the exact same result. If not, we did something wrong.
Any chance that you have a rolling distribution where something got upgraded?
So... unless the compiler specifically states that it is deterministic, the OP should just shrug his shoulders and accept it? IMHO, caprice should be expected in government policies, not in compilers. Am subscribing to this mostly because i find it intriguing and would like to be notified if csakthikumar ever finds the reason behind this.
Exactly this is the first time I am seeing like this. I preassumed compiler will always give the same output if the environment and code is not modified
Same code (no changes)
Same tools (no changes)
Same process/makefile (no changes)
Result EXACTLY the same.
I'd say for years, since the 70's, we either assemble, or compile. And once we had a release, we froze that code, along with the tools to build it and many, many times we verified that it generated exactly the same result. This used to be part of a submission process for one of my former employer's freeze process. We had to prove that we could regenerate the exact same result. If not, we did something wrong.
Any chance that you have a rolling distribution where something got upgraded?
I have also got this issue during code freeze process aka source code consistency process only. Also I am able to reproduce this issue. When I build the libs like 26 times I am able to find that the libs being built 25 times is different from the 26th time. Even though this 25 - 26 number is not consistent.
I know I wrote a few paragraphs, but I actually had a question at the end of that.Does sound like you answered though when you mention you can build repeatedly OK and then see a fault one time.
in my OP have mentioned that there is no changes in compiler or related tools or literally anything else in the build environment. On further analysis have found that when we have multiple local variable declaration that is where this sort of problem is happening Once I finish my deep analysis I will post a report over the same.
Theoretically there are a few tools available to detect [almost] any kind of changes, so you can compare two executions of the build process. But I'm not really sure you can do that in your case.
The changes could be: different source code, different tools, different environment, different os/platform/user/hardware, but unfortunately it can be simply the date which will be different every time.
Yes, in general from the same source the system should generate the same result, but without knowing the details hard to check what can influence your build process and what kind of differences have any effect on the result.
Theoretically there are a few tools available to detect [almost] any kind of changes, so you can compare two executions of the build process. But I'm not really sure you can do that in your case.
The changes could be: different source code, different tools, different environment, different os/platform/user/hardware, but unfortunately it can be simply the date which will be different every time.
Yes, in general from the same source the system should generate the same result, but without knowing the details hard to check what can influence your build process and what kind of differences have any effect on the result.
different source code, ---> my builds will have the sha id based on which the build has happened. This matches
different tools, ---> this is a CI environment which has not been modified or patched for the past 6 months atleast
different environment, ---> as above
different os/platform/user/hardware ---> as above
Adding to that our deliverable will be in terms of libs and for each platform we used to build 12 libs of which only 1 lib is mismatching on displaying the assembly similar to the one present in OP. It has been confirmed that only two instructions are swapped.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.