* [Caml-list] Is there some builtin function that flushes buffers on shutdown? @ 2017-02-03 8:56 Christoph Höger 2017-02-03 9:16 ` Nicolás Ojeda Bär 0 siblings, 1 reply; 6+ messages in thread From: Christoph Höger @ 2017-02-03 8:56 UTC (permalink / raw) To: caml-list [-- Attachment #1.1: Type: text/plain, Size: 937 bytes --] Dear all, I managed to manually link and run an object file generated by ocamlopt. A small part seems to be missing, however: ➜ llvmlink ocamlfind opt -package ANSITerminal -linkpkg -verbose -output-obj -o test.object.o test.ml ➜ llvmlink clang -I$(ocamlc -where) -lm wrapper.c test.object.o -o wrapper ~/.opam/4.04.0/lib/ocaml/libunix.a -ldl ~/.opam/4.04.0/lib/ocaml/libasmrun.a /home/choeger/.opam/4.04.0/lib/ANSITerminal/libANSITerminal_stubs.a These commands produce an executable output, but the screen remains empty. This changes, when I manually flush the stdout buffer in the code (I obtain the desired results then). Find attached the test sources. When I uncomment the Printf.printf in test.ml, everything seems to work fine. But when I compile the test using ocamlopt solely, this is not necessary. It seems some buffers do not get flushed here. Does anyone know, why? regards, Christoph [-- Attachment #1.2: Type: text/html, Size: 1145 bytes --] [-- Attachment #2: wrapper.c --] [-- Type: text/x-csrc, Size: 196 bytes --] #include <caml/callback.h> #include <stdio.h> int main(int argc, char ** argv) { int result; /* Initialize OCaml code */ caml_startup(argv); printf("finished\n"); return 0; } [-- Attachment #3: test.ml --] [-- Type: application/octet-stream, Size: 1165 bytes --] module T = ANSITerminal open Printf let colors = [T.Black; T.Red; T.Green; T.Yellow; T.Blue; T.Magenta; T.Cyan; T.White; T.Default] let color_to_string = function | T.Black -> "black" | T.Red -> "red" | T.Green -> "green" | T.Yellow -> "yellow" | T.Blue -> "blue" | T.Magenta -> "magent" | T.Cyan -> "cyan" | T.White -> "white" | T.Default -> "def" let () = (* Table *) let print_line fore = printf "%6s " (color_to_string fore); List.iter (fun back -> T.print_string [T.Foreground fore; T.Background back; ] " !Text! "; ) colors; print_string "\n" in Printf.eprintf "starting\n" ; T.erase T.Screen; T.set_cursor 1 1; print_string " "; List.iter (fun back -> printf "%6s " (color_to_string back)) colors; print_string "\n"; List.iter print_line colors; (* Effects *) T.print_string [T.Bold] "Bold "; T.print_string [T.Underlined] "Underlined "; T.print_string [T.Blink] "Blink "; T.print_string [T.Inverse] "Inverse "; T.print_string [T.Hidden] "Hidden"; (* uncomment to see results Printf.printf "%!"; *) print_string "<-- hidden\n" ; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Is there some builtin function that flushes buffers on shutdown? 2017-02-03 8:56 [Caml-list] Is there some builtin function that flushes buffers on shutdown? Christoph Höger @ 2017-02-03 9:16 ` Nicolás Ojeda Bär 2017-02-03 10:15 ` Christoph Höger 0 siblings, 1 reply; 6+ messages in thread From: Nicolás Ojeda Bär @ 2017-02-03 9:16 UTC (permalink / raw) To: Christoph Höger; +Cc: OCaml Mailing List [-- Attachment #1: Type: text/plain, Size: 1227 bytes --] Hi Christoph, I can't check now, but it sounds like you forgot to link $(ocamlc -where)/std_exit.o into your executable. Cheers! Nicolas On Fri, Feb 3, 2017 at 9:56 AM, Christoph Höger < christoph.hoeger@celeraone.com> wrote: > Dear all, > > I managed to manually link and run an object file generated by ocamlopt. A > small part seems to be missing, however: > > ➜ llvmlink ocamlfind opt -package ANSITerminal -linkpkg -verbose > -output-obj -o test.object.o test.ml > > ➜ llvmlink clang -I$(ocamlc -where) -lm wrapper.c test.object.o -o > wrapper ~/.opam/4.04.0/lib/ocaml/libunix.a -ldl ~/.opam/4.04.0/lib/ocaml/libasmrun.a > /home/choeger/.opam/4.04.0/lib/ANSITerminal/libANSITerminal_stubs.a > > These commands produce an executable output, but the screen remains empty. > This changes, when I manually flush the stdout buffer in the code (I obtain > the desired results then). > > Find attached the test sources. When I uncomment the Printf.printf in > test.ml, everything seems to work fine. But when I compile the test using > ocamlopt solely, this is not necessary. It seems some buffers do not get > flushed here. Does anyone know, why? > > regards, > > Christoph > > [-- Attachment #2: Type: text/html, Size: 1809 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Is there some builtin function that flushes buffers on shutdown? 2017-02-03 9:16 ` Nicolás Ojeda Bär @ 2017-02-03 10:15 ` Christoph Höger 2017-02-03 10:52 ` Nicolás Ojeda Bär 0 siblings, 1 reply; 6+ messages in thread From: Christoph Höger @ 2017-02-03 10:15 UTC (permalink / raw) To: Nicolás Ojeda Bär; +Cc: OCaml Mailing List [-- Attachment #1: Type: text/plain, Size: 1555 bytes --] That sounded totally reasonable, but is not the cause. When I think about it, it cannot work that way, since the linker should have complained about a missing symbol, right? On Fri, Feb 3, 2017 at 10:16 AM, Nicolás Ojeda Bär < nicolas.ojeda.bar@lexifi.com> wrote: > Hi Christoph, > > I can't check now, but it sounds like you forgot to link $(ocamlc > -where)/std_exit.o into your executable. > > Cheers! > Nicolas > > > On Fri, Feb 3, 2017 at 9:56 AM, Christoph Höger < > christoph.hoeger@celeraone.com> wrote: > >> Dear all, >> >> I managed to manually link and run an object file generated by ocamlopt. >> A small part seems to be missing, however: >> >> ➜ llvmlink ocamlfind opt -package ANSITerminal -linkpkg -verbose >> -output-obj -o test.object.o test.ml >> >> ➜ llvmlink clang -I$(ocamlc -where) -lm wrapper.c test.object.o -o >> wrapper ~/.opam/4.04.0/lib/ocaml/libunix.a -ldl >> ~/.opam/4.04.0/lib/ocaml/libasmrun.a /home/choeger/.opam/4.04.0/lib >> /ANSITerminal/libANSITerminal_stubs.a >> >> These commands produce an executable output, but the screen remains >> empty. This changes, when I manually flush the stdout buffer in the code (I >> obtain the desired results then). >> >> Find attached the test sources. When I uncomment the Printf.printf in >> test.ml, everything seems to work fine. But when I compile the test >> using ocamlopt solely, this is not necessary. It seems some buffers do not >> get flushed here. Does anyone know, why? >> >> regards, >> >> Christoph >> >> > [-- Attachment #2: Type: text/html, Size: 2436 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Is there some builtin function that flushes buffers on shutdown? 2017-02-03 10:15 ` Christoph Höger @ 2017-02-03 10:52 ` Nicolás Ojeda Bär 2017-02-03 11:37 ` Nicolás Ojeda Bär 0 siblings, 1 reply; 6+ messages in thread From: Nicolás Ojeda Bär @ 2017-02-03 10:52 UTC (permalink / raw) To: Christoph Höger; +Cc: OCaml Mailing List [-- Attachment #1: Type: text/plain, Size: 2002 bytes --] Hi Christoph, You are right, but that is because std_exit.cmx does not get linked by default when using -output-obj, so in fact you need to add it by hand: ocamlfind opt -package ANSITerminal -linkpkg -verbose -output-obj -o test.object.o test.ml std_exit.ml Cheers! Nicolas On Fri, Feb 3, 2017 at 11:15 AM, Christoph Höger < christoph.hoeger@celeraone.com> wrote: > That sounded totally reasonable, but is not the cause. When I think about > it, it cannot work that way, since the linker should have complained about > a missing symbol, right? > > On Fri, Feb 3, 2017 at 10:16 AM, Nicolás Ojeda Bär < > nicolas.ojeda.bar@lexifi.com> wrote: > >> Hi Christoph, >> >> I can't check now, but it sounds like you forgot to link $(ocamlc >> -where)/std_exit.o into your executable. >> >> Cheers! >> Nicolas >> >> >> On Fri, Feb 3, 2017 at 9:56 AM, Christoph Höger < >> christoph.hoeger@celeraone.com> wrote: >> >>> Dear all, >>> >>> I managed to manually link and run an object file generated by ocamlopt. >>> A small part seems to be missing, however: >>> >>> ➜ llvmlink ocamlfind opt -package ANSITerminal -linkpkg -verbose >>> -output-obj -o test.object.o test.ml >>> >>> ➜ llvmlink clang -I$(ocamlc -where) -lm wrapper.c test.object.o -o >>> wrapper ~/.opam/4.04.0/lib/ocaml/libunix.a -ldl >>> ~/.opam/4.04.0/lib/ocaml/libasmrun.a /home/choeger/.opam/4.04.0/lib >>> /ANSITerminal/libANSITerminal_stubs.a >>> >>> These commands produce an executable output, but the screen remains >>> empty. This changes, when I manually flush the stdout buffer in the code (I >>> obtain the desired results then). >>> >>> Find attached the test sources. When I uncomment the Printf.printf in >>> test.ml, everything seems to work fine. But when I compile the test >>> using ocamlopt solely, this is not necessary. It seems some buffers do not >>> get flushed here. Does anyone know, why? >>> >>> regards, >>> >>> Christoph >>> >>> >> > [-- Attachment #2: Type: text/html, Size: 3386 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Is there some builtin function that flushes buffers on shutdown? 2017-02-03 10:52 ` Nicolás Ojeda Bär @ 2017-02-03 11:37 ` Nicolás Ojeda Bär 2017-02-09 12:53 ` Christoph Höger 0 siblings, 1 reply; 6+ messages in thread From: Nicolás Ojeda Bär @ 2017-02-03 11:37 UTC (permalink / raw) To: Christoph Höger; +Cc: OCaml Mailing List [-- Attachment #1: Type: text/plain, Size: 2272 bytes --] That should be std_exit.cmx, not std_exit.ml. Sorry about the typo. Cheers, Nicolas On Fri, Feb 3, 2017 at 11:52 AM, Nicolás Ojeda Bär < nicolas.ojeda.bar@lexifi.com> wrote: > Hi Christoph, > > You are right, but that is because std_exit.cmx does not get linked by > default when using -output-obj, so > in fact you need to add it by hand: > > ocamlfind opt -package ANSITerminal -linkpkg -verbose -output-obj -o > test.object.o test.ml std_exit.ml > > Cheers! > Nicolas > > > > On Fri, Feb 3, 2017 at 11:15 AM, Christoph Höger < > christoph.hoeger@celeraone.com> wrote: > >> That sounded totally reasonable, but is not the cause. When I think about >> it, it cannot work that way, since the linker should have complained about >> a missing symbol, right? >> >> On Fri, Feb 3, 2017 at 10:16 AM, Nicolás Ojeda Bär < >> nicolas.ojeda.bar@lexifi.com> wrote: >> >>> Hi Christoph, >>> >>> I can't check now, but it sounds like you forgot to link $(ocamlc >>> -where)/std_exit.o into your executable. >>> >>> Cheers! >>> Nicolas >>> >>> >>> On Fri, Feb 3, 2017 at 9:56 AM, Christoph Höger < >>> christoph.hoeger@celeraone.com> wrote: >>> >>>> Dear all, >>>> >>>> I managed to manually link and run an object file generated by >>>> ocamlopt. A small part seems to be missing, however: >>>> >>>> ➜ llvmlink ocamlfind opt -package ANSITerminal -linkpkg -verbose >>>> -output-obj -o test.object.o test.ml >>>> >>>> ➜ llvmlink clang -I$(ocamlc -where) -lm wrapper.c test.object.o -o >>>> wrapper ~/.opam/4.04.0/lib/ocaml/libunix.a -ldl >>>> ~/.opam/4.04.0/lib/ocaml/libasmrun.a /home/choeger/.opam/4.04.0/lib >>>> /ANSITerminal/libANSITerminal_stubs.a >>>> >>>> These commands produce an executable output, but the screen remains >>>> empty. This changes, when I manually flush the stdout buffer in the code (I >>>> obtain the desired results then). >>>> >>>> Find attached the test sources. When I uncomment the Printf.printf in >>>> test.ml, everything seems to work fine. But when I compile the test >>>> using ocamlopt solely, this is not necessary. It seems some buffers do not >>>> get flushed here. Does anyone know, why? >>>> >>>> regards, >>>> >>>> Christoph >>>> >>>> >>> >> > [-- Attachment #2: Type: text/html, Size: 4143 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Is there some builtin function that flushes buffers on shutdown? 2017-02-03 11:37 ` Nicolás Ojeda Bär @ 2017-02-09 12:53 ` Christoph Höger 0 siblings, 0 replies; 6+ messages in thread From: Christoph Höger @ 2017-02-09 12:53 UTC (permalink / raw) To: Nicolás Ojeda Bär; +Cc: OCaml Mailing List [-- Attachment #1: Type: text/plain, Size: 2617 bytes --] Thanks, that worked like a charm. As a side note: The order of arguments is important. test.ml std_exit.cmx will work, while std_exit.cmx test.ml will not. On Fri, Feb 3, 2017 at 12:37 PM, Nicolás Ojeda Bär < nicolas.ojeda.bar@lexifi.com> wrote: > That should be std_exit.cmx, not std_exit.ml. > > Sorry about the typo. > > Cheers, > Nicolas > > > On Fri, Feb 3, 2017 at 11:52 AM, Nicolás Ojeda Bär < > nicolas.ojeda.bar@lexifi.com> wrote: > >> Hi Christoph, >> >> You are right, but that is because std_exit.cmx does not get linked by >> default when using -output-obj, so >> in fact you need to add it by hand: >> >> ocamlfind opt -package ANSITerminal -linkpkg -verbose -output-obj -o >> test.object.o test.ml std_exit.ml >> >> Cheers! >> Nicolas >> >> >> >> On Fri, Feb 3, 2017 at 11:15 AM, Christoph Höger < >> christoph.hoeger@celeraone.com> wrote: >> >>> That sounded totally reasonable, but is not the cause. When I think >>> about it, it cannot work that way, since the linker should have complained >>> about a missing symbol, right? >>> >>> On Fri, Feb 3, 2017 at 10:16 AM, Nicolás Ojeda Bär < >>> nicolas.ojeda.bar@lexifi.com> wrote: >>> >>>> Hi Christoph, >>>> >>>> I can't check now, but it sounds like you forgot to link $(ocamlc >>>> -where)/std_exit.o into your executable. >>>> >>>> Cheers! >>>> Nicolas >>>> >>>> >>>> On Fri, Feb 3, 2017 at 9:56 AM, Christoph Höger < >>>> christoph.hoeger@celeraone.com> wrote: >>>> >>>>> Dear all, >>>>> >>>>> I managed to manually link and run an object file generated by >>>>> ocamlopt. A small part seems to be missing, however: >>>>> >>>>> ➜ llvmlink ocamlfind opt -package ANSITerminal -linkpkg -verbose >>>>> -output-obj -o test.object.o test.ml >>>>> >>>>> ➜ llvmlink clang -I$(ocamlc -where) -lm wrapper.c test.object.o -o >>>>> wrapper ~/.opam/4.04.0/lib/ocaml/libunix.a -ldl >>>>> ~/.opam/4.04.0/lib/ocaml/libasmrun.a /home/choeger/.opam/4.04.0/lib >>>>> /ANSITerminal/libANSITerminal_stubs.a >>>>> >>>>> These commands produce an executable output, but the screen remains >>>>> empty. This changes, when I manually flush the stdout buffer in the code (I >>>>> obtain the desired results then). >>>>> >>>>> Find attached the test sources. When I uncomment the Printf.printf in >>>>> test.ml, everything seems to work fine. But when I compile the test >>>>> using ocamlopt solely, this is not necessary. It seems some buffers do not >>>>> get flushed here. Does anyone know, why? >>>>> >>>>> regards, >>>>> >>>>> Christoph >>>>> >>>>> >>>> >>> >> > [-- Attachment #2: Type: text/html, Size: 4966 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-02-09 12:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-02-03 8:56 [Caml-list] Is there some builtin function that flushes buffers on shutdown? Christoph Höger 2017-02-03 9:16 ` Nicolás Ojeda Bär 2017-02-03 10:15 ` Christoph Höger 2017-02-03 10:52 ` Nicolás Ojeda Bär 2017-02-03 11:37 ` Nicolás Ojeda Bär 2017-02-09 12:53 ` Christoph Höger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox