Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msvc linker response file should be UTF-16 encoded when possible #36

Closed
nojb opened this issue Jun 30, 2017 · 1 comment
Closed

msvc linker response file should be UTF-16 encoded when possible #36

nojb opened this issue Jun 30, 2017 · 1 comment

Comments

@nojb
Copy link
Collaborator

nojb commented Jun 30, 2017

Currently we use a response file to pass arguments to the msvc linker when the command line is too long.

Supported encodings for the response file are ANSI (currently used) and UTF-16: see https://msdn.microsoft.com/en-us/library/xwy0e8f2(v=vs.140).aspx.

In order to make flexlink work with Unicode (cf ocaml/ocaml#1200) we need to use UTF-16 (here I am thinking about the situation when our OCaml strings are UTF-8). I made a quick proof of concept with a handwritten UTF-8 decoder and it fixed the problems I was seeing.

Ideally this functionality would be enabled as soon as flexlink is compiled with a Unicode-enabled ocamlc, but am not sure if this is easy to do.

Ideas ?

@nojb
Copy link
Collaborator Author

nojb commented Sep 21, 2017

This has been addressed in #34.

@nojb nojb closed this as completed Sep 21, 2017
punchagan added a commit to punchagan/flexdll that referenced this issue Jan 25, 2025
Based on inputs from @dra27, response files were added to gcc 4.2.0 [1],
but Cygwin was stuck on gcc 3.4.4 for ages until mingw-w64 was
introduced at gcc 4.5 (Cygwin's gcc itself still lagged for a while) cf. [2].

So, in 2008 [3], it was correct to avoid using response files with
CYGWIN and MINGW & MINGW64, but now all three platforms could benefit
from using response files. This commit enables the use of response files
for all toolchains except the GNAT ones.

The UTF-16 conversion of paths seems to have been primarily implemented
for MSVC[4] and causes issues with MINGW64. The linker fails with a
"file not found" error with a weird 2 character file path, which seems
like an encoding issue when reading the Byte Order Mark written during
the conversion. This commit turns off the UTF-16 conversion when not
using the MSVC or LIGHTLD toolchains.

[1] - gcc-mirror/gcc@9d53053
[2] - http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2010/09/14/020013/index.html
[3] - ocaml@fb84938
[4] - ocaml#36
punchagan added a commit to punchagan/flexdll that referenced this issue Jan 25, 2025
Based on inputs from @dra27, response files were added to gcc 4.2.0 [1],
but Cygwin was stuck on gcc 3.4.4 for ages until mingw-w64 was
introduced at gcc 4.5 (Cygwin's gcc itself still lagged for a while) cf. [2].

So, in 2008 [3], it was correct to avoid using response files with
CYGWIN, MINGW & MINGW64, but now all three platforms could benefit from
using response files. This commit enables the use of response files for
all toolchains except the GNAT ones.

The UTF-16 conversion of paths seems to have been primarily implemented
for MSVC[4] and causes issues with MINGW64. The linker fails with a
"file not found" error with a weird 2 character file path, which seems
like an encoding issue when reading the Byte Order Mark written during
the conversion. This commit turns off the UTF-16 conversion when not
using the MSVC or LIGHTLD toolchains.

[1] - gcc-mirror/gcc@9d53053
[2] - http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2010/09/14/020013/index.html
[3] - ocaml@fb84938
[4] - ocaml#36
punchagan added a commit to punchagan/flexdll that referenced this issue Jan 25, 2025
Based on inputs from @dra27, response files were added to gcc 4.2.0 [1],
but Cygwin was stuck on gcc 3.4.4 for ages until mingw-w64 was
introduced at gcc 4.5 (Cygwin's gcc itself still lagged for a while) cf. [2].

So, in 2008 [3], it was correct to avoid using response files with
CYGWIN, MINGW & MINGW64, but now all three platforms could benefit from
using response files. This commit enables the use of response files for
all toolchains except the GNAT ones.

The UTF-16 conversion of paths seems to have been primarily implemented
for MSVC[4] and causes issues with MINGW64. The linker fails with a
"file not found" error with a weird 2 character file path, which seems
like an encoding issue when reading the Byte Order Mark written during
the conversion. This commit turns off the UTF-16 conversion when not
using the MSVC or LIGHTLD toolchains.

[1] - gcc-mirror/gcc@9d53053
[2] - http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2010/09/14/020013/index.html
[3] - ocaml@fb84938
[4] - ocaml#36
punchagan added a commit to punchagan/flexdll that referenced this issue Jan 28, 2025
Response files were added to gcc 4.2.0 [1], but Cygwin was stuck on gcc
3.4.4 for ages until mingw-w64 was introduced at gcc 4.5 (Cygwin's gcc
itself still lagged for a while) cf. [2]. (Based on inputs from @dra27).

So, in 2008 [3], it was correct to avoid using response files with
CYGWIN & MINGW. Later, support was added for the GNAT toolchain based on
the MINGW toolchain, also avoiding the use of response files. But, now
all the platforms could benefit from using response files. This commit
enables the use of response files for all toolchains, including GNAT
since the GNAT compiler is based on gcc [4].

The UTF-16 conversion of paths seems to have been primarily implemented
for MSVC[5] and causes issues with MINGW64. The linker fails with a
"file not found" error with a weird 2 character file path, which seems
like an encoding issue when reading the Byte Order Mark written during
the conversion. This commit turns off the UTF-16 conversion when not
using the MSVC or LIGHTLD toolchains.

[1] - gcc-mirror/gcc@9d53053
[2] - http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2010/09/14/020013/index.html
[3] -
ocaml@fb84938
[4] - ocaml#151 (comment)
[5] - ocaml#36
punchagan added a commit to punchagan/flexdll that referenced this issue Feb 17, 2025
Response files were added to gcc 4.2.0 [1], but Cygwin was stuck on gcc
3.4.4 for ages until mingw-w64 was introduced at gcc 4.5 (Cygwin's gcc
itself still lagged for a while) cf. [2]. (Based on inputs from @dra27).

So, in 2008 [3], it was correct to avoid using response files with
CYGWIN & MINGW. Later, support was added for the GNAT toolchain based on
the MINGW toolchain, also avoiding the use of response files. But, now
all the platforms could benefit from using response files. This commit
enables the use of response files for all toolchains, including GNAT
since the GNAT compiler is based on gcc [4].

The UTF-16 conversion of paths seems to have been primarily implemented
for MSVC[5] and causes issues with MINGW64. The linker fails with a
"file not found" error with a weird 2 character file path, which seems
like an encoding issue when reading the Byte Order Mark written during
the conversion. This commit turns off the UTF-16 conversion when not
using the MSVC or LIGHTLD toolchains.

[1] - gcc-mirror/gcc@9d53053
[2] - http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2010/09/14/020013/index.html
[3] -
ocaml@fb84938
[4] - ocaml#151 (comment)
[5] - ocaml#36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant