Don't generate #! headers over 127 characters#8622
Conversation
A #! line should not exceed 128 characters (including the \0 terminator). This adds a test - both to the generation of the camlheader files and also to the -use-runtime flag which falls back to #!/bin/sh and uses exec to invoke the the interpreter.
|
I learned another silly limitation today :-) For the record, some documentation about |
|
Just following up #2309 (comment) here. There is a problem with this patch, in that the "TODO" comment is more urgent than I realised. So the problem is that this fix does not really work - it needs a little work which means it will be better left out of 4.09 and hopefully be fixed up completely for 4.10 |
| (* shebang mustn't exceed 128 including the #! and \0 *) | ||
| if String.length runtime > 125 then | ||
| "/bin/sh\n\ | ||
| exec \"" ^ runtime ^ "\" \"$0\" \"$@\"" |
There was a problem hiding this comment.
You should use Filename.quote here to guard against paths with " in them.
There was a problem hiding this comment.
Better late than never, but this will be addressed in the set of PRs for allowing the compiler to be relocated.
As it happens, it's not a bug at the moment inasmuch as you can't get here because Symtable.init doesn't quote the runtime either. Fix will be ready before 4.13.
#!lines should not exceed 128 characters, including the null terminator. On Linux, breaking this has confusing consequences:This PR detects the worst case in
configureand reverts to this pattern:The same logic is applied by
ocamlcfor the-use-runtimeflag. I fear for @gasche's sanity if we attempt to embed thestrlenfunction as a GNU make macro, so I've chosen to determine statically inconfigurewhether the path to ocamlrun/ocamlrund/ocamlruni might be too long, rather than dynamically determine it inMakefile.This issue, coupled with a related problem in opam, has caused considerable pain for @ctk21 and our searches showed that this may have hit other packagers of OCaml in the past. It's comparatively easy to hit this scenario when building opam switches with lots of
+variantadditions or fakeroot package builds, etc.I don't propose this for 4.08, although I think it might be worth back-porting to opam-repository once the fix is accepted here.