[fpc-devel] Cross-compiling and warnings from linker
Hello, Using cross-compiler from x86-linux to arm-linux, I keep getting a lot of warnings at the linking stage of my programs, in the form: /opt/[...]/arm-linux-gnueabihf-ld: warning: library search path "/usr/lib/eject/" is unsafe for cross-compilation /opt/[...]/arm-linux-gnueabihf-ld: warning: warning: library search path "/usr/lib/console-setup/" is unsafe for cross-compilation [...] for virtually every sub-directory in /usr/lib. FPC 3.2.0 and 3.2.2 both have this issue. This makes me suspect FPC cross produces instructions for the linker to search for files in wrong directories, where host libraries reside, that could lead to unpredictable results, and then tons of the warnings are really annoying. What's the way to fix this? Thanks, -- Sergey Organov ___ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Cross-compiling and warnings from linker
Le 10/11/2021 à 21:19, Sergey Organov via fpc-devel a écrit : Hello, Using cross-compiler from x86-linux to arm-linux, I keep getting a lot of warnings at the linking stage of my programs, in the form: /opt/[...]/arm-linux-gnueabihf-ld: warning: library search path "/usr/lib/eject/" is unsafe for cross-compilation /opt/[...]/arm-linux-gnueabihf-ld: warning: warning: library search path "/usr/lib/console-setup/" is unsafe for cross-compilation [...] for virtually every sub-directory in /usr/lib. FPC 3.2.0 and 3.2.2 both have this issue. This makes me suspect FPC cross produces instructions for the linker to search for files in wrong directories, where host libraries reside, that could lead to unpredictable results, and then tons of the warnings are really annoying. What's the way to fix this? Try to use -Xd compiler option ~/bin$ fpc -h | grep -- -Xd -XdDo not search default library path (sometimes required for cross-compiling when not using -XR) Pierre ___ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Cross-compiling and warnings from linker
On 2021-11-12 10:20, Pierre Muller via fpc-devel wrote: Le 10/11/2021 à 21:19, Sergey Organov via fpc-devel a écrit : Hello, Using cross-compiler from x86-linux to arm-linux, I keep getting a lot of warnings at the linking stage of my programs, in the form: /opt/[...]/arm-linux-gnueabihf-ld: warning: library search path "/usr/lib/eject/" is unsafe for cross-compilation /opt/[...]/arm-linux-gnueabihf-ld: warning: warning: library search path "/usr/lib/console-setup/" is unsafe for cross-compilation [...] for virtually every sub-directory in /usr/lib. FPC 3.2.0 and 3.2.2 both have this issue. This makes me suspect FPC cross produces instructions for the linker to search for files in wrong directories, where host libraries reside, that could lead to unpredictable results, and then tons of the warnings are really annoying. What's the way to fix this? Try to use -Xd compiler option ~/bin$ fpc -h | grep -- -Xd -XdDo not search default library path (sometimes required for cross-compiling when not using -XR) Or better: use -XR/path/to/cross-root. -Xd is a hack that predates the introduction of -XR. Jonas ___ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] Optimisation and thread safety
Hi everyone, I have a question when it comes to optimising memory reads and writes. What are the rules for FPC when it comes to writing to memory and then reading from it later within a single subroutine? For example, say I had this pair of commands: movq %rdx,-584(%rbp) movl -584(%rbp),%eax That could easily be converted to "movl %edx,%eax", especially as %rbp is likely pointing to the top of the stack. But if the reference uses different registers, would it still be safe to make this optimisation given that the scheduler could suspend the thread in between the two instructions and then another thread writes to the same memory block before control is returned? I am aware of other examples that require caution. For example: movslq -608(%rbp),%rdx subl %eax,-84(%rbp,%rdx,4) movslq -608(%rbp),%rdx Here it might be tempting to remove the second "movslq" instruction, but the value of %rdx could happen to be equal to -131, which would allow the subl instruction to modify -608(%rbp), and in this situation, it's quite likely if a malicious input is given to the program to manipulate the value stored at -608(%rbp) and invoke a buffer overrun. So in conclusion, theoretically, where is it perfectly safe to assume the value in memory hasn't changed, where would it be permissible only under -O4 and where must it not be optimised at all? Gareth aka. Kit P.S. Assembly examples were taken from the System unit. -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus ___ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel