How to identify the xcode version and compiler version used to build an artifact like object file or binary built on mac?
Asked Answered
M

0

2

If we write a hello world.cpp and build using g++ in linux, doing an objdump or a strings can expose the compiler used in linux.

Is there a way to know which compiler generated a static library?

I am not able to use the same in mac. For instance, the following artifact compiled using clang++,

#include <iostream.h>

int main() {
  std::cout<<"Hello world";
  return 0;
}

running objdump -s -j .comment a.out gives this:

a.out: file format Mach-O 64-bit x86-64

How to we identify the compiler version from a mac artifact? How does the same work on windows?

Running a strings -a does not show any reference to "clang-" string.

Micrometeorology answered 10/1, 2020 at 7:6 Comment(3)
If you build using GCC on macOS, does the generated file contain any identifiable information about the compiler then? Then the lack of identifying information is a way to identify that the file may have been created by Clang.Abm
Independent of using GCC or Clang, the compiler version is not available in .comment or any other section of the artifact.Micrometeorology
AFAICT, using the -g (debugging information) option includes useful information like the compiler version; omitting it means there is no useful metadata.Indefatigable

© 2022 - 2024 — McMap. All rights reserved.