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

Fix headernt.c & -output-obj Unicode support #1362

Merged
merged 5 commits into from
Sep 27, 2017

Conversation

nojb
Copy link
Contributor

@nojb nojb commented Sep 21, 2017

This is a follow-up to #1200. It does three things:

  • Fixes a bad rebase of read_runtime_path of headernt.c
  • Fixes the C signature of the argv argument in the C file generated by -output-obj
  • Uses WriteConsole in headernt.c to properly print Unicode pathnames in error messages.

Together with #1357 this should fix the remaining Windows testsuite errors.

/cc @dra27

@nojb nojb changed the base branch from 4.06 to trunk September 21, 2017 14:53
@nojb
Copy link
Contributor Author

nojb commented Sep 21, 2017

Rebased on trunk.

Copy link
Member

@damiendoligez damiendoligez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It's up to you if you want to wait for a review from @dra27, who is away until Monday.

@nojb
Copy link
Contributor Author

nojb commented Sep 22, 2017

Thanks! No problem waiting for David's review (only downside is that AppVeyor will remain broken until then).

@damiendoligez damiendoligez added this to the 4.06.0 milestone Sep 22, 2017
@nojb
Copy link
Contributor Author

nojb commented Sep 26, 2017

I was waiting for @dra27's review, but I think we could/should merge this now since it fixes two bugs and several testsuite failures. We can always revisit if necessary.

@shindere
Copy link
Contributor

shindere commented Sep 26, 2017 via email

@gasche
Copy link
Member

gasche commented Sep 26, 2017

On the other hand, (1) this stuff seems tricky and (2) it's a pain to fix-after-the-fact when there is a release branch. Damien (or someone else) may want to merge it now, but I'll personally wait to merge unless @dra27 signals that he is too busy with other things.

@dra27
Copy link
Member

dra27 commented Sep 26, 2017

Sorry - fully back from vacation tomorrow (though I may have a chance to give this and #1363 a review later today)

@@ -487,7 +487,7 @@ let link_bytecode_as_c ppf tolink outfile =
Symtable.output_primitive_table outchan;
(* The entry point *)
output_string outchan "\
\nvoid caml_startup(char ** argv)\
\nvoid caml_startup(charnat ** argv)\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be renamed to char_os once the other PR is merged, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, will update as necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interests of getting at least one of our CI systems back up and running, can we merge this before #1363?

static char str[MAX_PATH];

if (GetConsoleMode(hOut, &consoleMode) != 0) { /* The output stream is a Console */
WriteConsoleW(hOut, wstr, wcslen(wstr), &numwritten, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: do we actually need the 'W' suffix here? I thought we were now compiling in a mode where unprefixed functions are aliases for *W ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right. Will fix.

if (GetConsoleMode(hOut, &consoleMode) != 0) { /* The output stream is a Console */
WriteConsoleW(hOut, wstr, wcslen(wstr), &numwritten, NULL);
} else { /* The output stream is redirected */
len = WideCharToMultiByte(CP, 0, wstr, wcslen(wstr), str, sizeof(str), NULL, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very unimportant, but I wonder if in principle it wouldn't be better to translate to UTF-8 here (it could be that the displayed filename cannot be represented in the current 8-bit codepage). Or is the idea of an UTF-8 encoded text file crazy under Windows?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed the fact that CP is indeed UTF-8 when OCaml is configured with Unicode support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely I think it makes good sense! I just did it this way to preserve existing behavior.

@nojb
Copy link
Contributor Author

nojb commented Sep 26, 2017

Wohoo, all AppVeyor tests pass! @shindere @dra27

Travis failures seem unrelated.

@shindere
Copy link
Contributor

shindere commented Sep 26, 2017 via email

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - cosmetic tweak to the exec_tests disabling only

@@ -9,7 +9,7 @@ C_FILES=mkfiles
.PHONY: test
test:
@if echo 'let () = exit (if Config.windows_unicode then 0 else 1)' | $(OCAML) -I $(OTOPDIR)/utils config.cmo -stdin; then \
$(MAKE) printargv.exe printenv.exe symlink_tests.precheck && \
$(MAKE) printargv.exe printenv.exe symlink_tests.precheck exec_tests.precheck && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little convoluted to me - why not just create exec_tests.precheck with exit 1 in it - the entry in .gitignore is then not necessary and lines 22-25 below can just be deleted?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exec_tests.precheck file could also then include a comment as to why the tests are disabled (stability - which I will look into, as I have an idea what it is...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested, thanks!

@@ -487,7 +487,7 @@ let link_bytecode_as_c ppf tolink outfile =
Symtable.output_primitive_table outchan;
(* The entry point *)
output_string outchan "\
\nvoid caml_startup(char ** argv)\
\nvoid caml_startup(charnat ** argv)\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interests of getting at least one of our CI systems back up and running, can we merge this before #1363?

@dra27
Copy link
Member

dra27 commented Sep 27, 2017

Doesn't have to be done here - but are there tests we could add for the -output-obj failure and similarly for headernt producing garbage when passed Unicode?

@dra27
Copy link
Member

dra27 commented Sep 27, 2017

I've just popped this branch into Inria CI's precheck

@dra27
Copy link
Member

dra27 commented Sep 27, 2017

Lovely, thanks - let's let AppVeyor run through and then merge and cherry-pick. The Travis failures are identical to the current ones on trunk, so I agree that they don't appear to be related.

@shindere
Copy link
Contributor

shindere commented Sep 27, 2017 via email

@shindere
Copy link
Contributor

shindere commented Sep 27, 2017 via email

@nojb
Copy link
Contributor Author

nojb commented Sep 27, 2017

@shindere wrote:

What's the problem exactly with Travis?

64-bit builds fail with dozens of errors like this one:

... testing 'fileio.ml': ocamlcFile "fileio.ml", line 1:
Error: Error on dynamically loaded library: /home/travis/build/ocaml/ocaml/testsuite/../otherlibs/unix/dllunix.so: /home/travis/build/ocaml/ocaml/testsuite/../otherlibs/unix/dllunix.so: undefined symbol: caml_atom_table

@gasche
Copy link
Member

gasche commented Sep 27, 2017

The errors all look similar to this one:

Running tests from 'tests/lib-bigarray' ...
... testing 'bigarrays.ml': ocamlcFile "bigarrays.ml", line 1:
Error: Error on dynamically loaded library: /home/travis/build/ocaml/ocaml/testsuite/../otherlibs/unix/dllunix.so: /home/travis/build/ocaml/ocaml/testsuite/../otherlibs/unix/dllunix.so: undefined symbol: caml_atom_table

This is unrelated to the present PR, but it's a recent breakage. I'll send an email.

@shindere
Copy link
Contributor

shindere commented Sep 27, 2017 via email

@dra27 dra27 merged commit 99878e4 into ocaml:trunk Sep 27, 2017
@nojb
Copy link
Contributor Author

nojb commented Sep 27, 2017

Thanks!

@dra27
Copy link
Member

dra27 commented Sep 27, 2017

Cherry-picked to 4.06 in 36e0a3b

EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
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

Successfully merging this pull request may close these issues.

6 participants