Repository navigation
Improve flexlink support on Unix (for cross-compiling contexts) - #157
Conversation
dfdd173 to
5aa7e28
Compare
dra27
left a comment
There was a problem hiding this comment.
Given that flexlink runs on both Sys.cygwin and Sys.win32 already, I'd possibly change the guards to be written in terms of Sys.unix instead (but that's probably just paranoia).
I'm not following the need for the exec bit yet (and therefore as to whether it should be guarded if Sys.unix then instead?)
| (* note: for Cygwin, using bash allow to follow symlinks to find | ||
| gcc... *) | ||
| if !toolchain = `CYGWIN64 || | ||
| if not Sys.win32 || !toolchain = `CYGWIN64 || |
There was a problem hiding this comment.
I don't think it matters, but given that this works if flexlink is on either native Windows or Cygwin, why not instead have if Sys.unix ||?
There was a problem hiding this comment.
I'm struggling to find a counter-example, so your idea must work.
| String.concat " " | ||
| (List.map (fun f -> if f = "" then f else Filename.quote f) lst) in | ||
| if String.length s >= 1024 && cmdline.may_use_response_file then Filename.quote (build_diversion lst) | ||
| if (Sys.win32 || Sys.cygwin) && String.length s >= 1024 && cmdline.may_use_response_file then Filename.quote (build_diversion lst) |
There was a problem hiding this comment.
| if (Sys.win32 || Sys.cygwin) && String.length s >= 1024 && cmdline.may_use_response_file then Filename.quote (build_diversion lst) | |
| if not Sys.unix && String.length s >= 1024 && cmdline.may_use_response_file then Filename.quote (build_diversion lst) |
| else | ||
| begin | ||
| let (cfn, oc) = open_temp_file "longcmd" ".sh" in | ||
| output_string oc "exec "; |
There was a problem hiding this comment.
Is this definitely correct? The command before was going to go via Sys.command (i.e. "sh -c"-like), which this in theory breaks?
There was a problem hiding this comment.
The command goes into a bash file that's executed as bash longcmdxxxxxx.sh below. As it's always a single invocation (no pipes, no command chains) and sometimes redirections, I think it's exactly the use-case for exec. Am I mistaken?
There was a problem hiding this comment.
Ah, I see what you mean. The whole thing boils down to sh -c 'bash longcmdxxxxxx.sh'. Better be safe than sorry, I'll revert this bit.
dra27
left a comment
There was a problem hiding this comment.
Needs a rebase, but otherwise good to go, thank you!
Use link.exe/lld-link.exe /? option to avoid lld-link complaining about no input files. Pass /nologo just in case, to avoid Microsoft's copyright prompt.
When flexlink runs on Unix in cross-compiling contexts, it shouldn't use
cmd.exeor batch syntax, or response files.