Re: Python recompile
James Kuyper <[email protected]>
| Newsgroups | comp.lang.c,comp.lang.c++,comp.lang.python |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On 3/3/25 12:20, Waldek Hebisch wrote: ... > The question is about C implementation. Namely, the bible for > this group, that is C standard requires C implementation to > produce executables. And making executable from C sources > it at core of the OP question. Fact that compiling this source > is supposed to produce Python interpreter or maybe some > supporting shared library is irrelevant here. > > One could call the problem "Linux problem". Namely, many > (maybe all) Linux distribution modify(ed) gcc so that creating > position independent executables is the default and to > prevent this one need '-no-pie' at final stage. And to > generate position independent executable all code has to > be compiled as position independent code which needs '-fPIC' > option. Similarly, if OP is trying to create shared > library, then on Linux all code inluded in the shared > librayr must be compiled as position independent code, > that is using '-fPIC'. > > Dismissing this as linker problem misses important > points: > - linking is considerd part of C implementation > - '-fPIC' is option for compiler proper > - '-no-pie' is handled by the compiler driver Here is the entirety of what the C standard says about translation phase 8, where programs are linked together: "All external object and function references are resolved. Library components are linked to satisfy external references to functions and objects not defined in the current translation. All such translator output is collected into a program image which contains information needed for execution in its execution environment." (5.1.2.2p8) Please tell me what that says that is relevant to the solution of this problem? The PIC in that option refers to "Position Independent Code", a topic about which the C standard says nothing. Whether or not that option is needed or even helpful is outside the scope of C. > And frankly, making executables or shared library from > C code is real world thing that C programmer want to do > and non-programmers would not do. More directly to the point, programmers who aren't C programmers also want to do it, and how it is done has nothing to do with C, and a lot to do with the linker. The linker can be language-neutral, and in my experience usually is, at least on the Unix-like platforms that I have the most experience on (though I have heard of some language-specific linkers). >