Live data from Hacker News

Incremental Compilation

blog.rust-lang.org

71–74 of 74 posts

Re: Incremental Compilation

#71
post #30
post #29

Since rust compiles to native machine code (bytes), how does it calculate the starting address of the code? for example, If there is a JMP instruction, JMP takes an address as an operand most likely -- Doesn't the kernel determine the starting address, or is the starting address the address returned by mmap?

Modern amd64 code is position-independent, so the JMP address is relative. On other architectures, it's the linker's job to convert symbolic addresses and it can choose all the addresses in one go as it's the final stage producting the executable.

Relative to what, the start address? Does rust determine the start address from the return value of `mmap`?

Re: Incremental Compilation

#72
post #59

Earlier quoted context omitted.

> Except for inlineable functions and templates in C++—which become a greater and greater fraction of code the more "modern" your C++ gets. The C++ ABI is currently not portable anyway. So the concern about templates (or any C++ features) forcing you to put the implementation into the header file would not apply in the scenario dllthomas was referring to: If you want to distribute your library as a binary object and…

> If you want to distribute your library as a binary object and a separate source-form interface/header today, you'll have to use a (wrapper) C API. Regardless of how "modern" the C++ code is. Not really. Those of us on Windows make use of COM, or since Windows 8, UWP components (formally known as WinRT).

Yes, but this is only a solution if your library is only targeting windows.

If you want users of any standards-compliant C++ implementation to be able to use your library today, you'll still have to go with c-abi symbols or ship the sources. All other worakrounds are vendor-specific and not part of the standard.

[Of course even objects containing only C symbols are not portable across platforms either, but at least the C ABI/calling convention is more or less strictly defined for any given target platform. Assuming no other platform-specific stuff like glibc is used]

Re: Incremental Compilation

#74
post #71
post #30

Earlier quoted context omitted.

Modern amd64 code is position-independent, so the JMP address is relative. On other architectures, it's the linker's job to convert symbolic addresses and it can choose all the addresses in one go as it's the final stage producting the executable.

Relative to what, the start address? Does rust determine the start address from the return value of `mmap`?

Relative to the current instruction pointer aka program counter. You say things like "JMP -100 bytes".
Post reply on HN