https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84288

            Bug ID: 84288
           Summary: Support jit on Solaris
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: jit
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
  Target Milestone: ---
              Host: *-*-solaris2.*
            Target: *-*-solaris2.*
             Build: *-*-solaris2.*

Created attachment 43373
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43373&action=edit
Initial hacky patch

I just tried building mainline on Solaris (i386-pc-solaris2.11, but the issues
are most likely independent of the actual OS version) and ran into a couple of
issues:

* Solaris ld doesn't support --version-script.  However, the version script
  used for libgccjit.so, doesn't use any gld extensions, so one can just use
  -M instead.  I've added code to gcc/configure.ac to detect the proper option
  to use.

* Compilation failed here:

/vol/gcc/src/hg/trunk/local/gcc/jit/jit-playback.c: In member function 'void
gcc::jit::playback::compile_to_file::copy_file(const char*, const char*)':
/vol/gcc/src/hg/trunk/local/gcc/jit/jit-playback.c:2111:25: error: format '%ld'
expects argument of type 'long int', but argument 3 has type 'std::size_t' {aka
'unsigned int'} [-Werror=format=]
     get_logger ()->log ("total bytes copied: %ld", total_sz_out);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~

  Fixed by casting total_sz_out to long.

* Solaris ld doesn't support --export-dynamic (and doesn't need it; ld behaves
  like the option is on out of the box).  Instead of configuring that, I chose
  to just use -rdynamic in jit.exp instead.

* If DejaGnu is installed into a non-system directory, dejagnu.h isn't found
  compiling the tests.  I've hacked around this by hardcoding a matching -I
  option in jit.exp.

* With DejaGnu 1.6.1, all tests FAIL like this:

/vol/gcc/include/dejagnu.h:43:12: error: 'xpassed' defined but not used
[-Werror=unused-variable]
cc1: all warnings being treated as errors

  xpassed is only used in the C++ part of dejagnu.h.  This problem is still
  present in the current git master.  Wrapped in #ifdef __cplusplus in the 
  local copy for now.

* A couple of tests FAIL like this:

        FAILED: test-combination.c.exe iteration 1 of 5:
make_tests_of_ptr_constants: actual: "(void *)deadbeef" != expected: "(void
*)0xdeadbeef"
incorrect valuen
FAIL:  test-combination.c.exe iteration 1 of 5: make_tests_of_ptr_constants:
actual: "(void *)deadbeef" != expected: "(void *)0xdeadbeef"

  The problem is that Solaris libc doesn't prefix pointers with 0x.  For the 
  moment, I've hacked around this with code inside __sun__ && __svr4__.  The
  proper way could be to introduce config/xm-sol2.h defining HOST_PTR_PRINTF
  and using that where appropriate.

* When gcc is configured with Solaris as and ld, a couple of tests FAIL like
  this:

        NOTE: test-compile-to-assembler.c.exe iteration 2 of 5: writing
reproducer to ./test-compile-to-assembler.c.exe.reproducer.c
./test-compile-to-assembler.c.exe: error: in get, at cgraph.h:404
0xfcfd4d3a symtab_node::get(tree_node const*)
        /vol/gcc/src/hg/trunk/local/gcc/cgraph.h:401
0xfcfd4d3a decl_comdat_group(tree_node const*)
        /vol/gcc/src/hg/trunk/local/gcc/tree.c:708
0xfd0ce378 solaris_define_comdat_signature(comdat_entry**, void*)
        /vol/gcc/src/hg/trunk/local/gcc/config/sol2.c:267
0xfd0ce6d6 void hash_table<comdat_entry_hasher,
xcallocator>::traverse_noresize<void*,
&(solaris_define_comdat_signature(comdat_entry**, void*))>(void*)
        /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:969
0xfd0ce6d6 void hash_table<comdat_entry_hasher, xcallocator>::traverse<void*,
&(solaris_define_comdat_signature(comdat_entry**, void*))>(void*)
        /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:990
0xfd0ce6d6 solaris_file_end()
        /vol/gcc/src/hg/trunk/local/gcc/config/sol2.c:291
[...]
FAIL: test-compile-to-assembler.c.exe: non-zero exit code: 7862 exp9 0 4


#0  0xfc2befe0 in exit () from /lib/libc.so.1
#1  0xfded54b5 in diagnostic_action_after_output (
    context=0xfe5df640 <global_diagnostic_context>, diag_kind=DK_ICE)
    at /vol/gcc/src/hg/trunk/local/gcc/diagnostic.c:533
#2  0xfded5e34 in diagnostic_report_diagnostic (context=<optimized out>, 
    diagnostic=<optimized out>)
    at /vol/gcc/src/hg/trunk/local/gcc/diagnostic.c:995
#3  0xfded618b in diagnostic_impl (richloc=0xfeffd814, opt=-1, 
    gmsgid=0xfce827f4 "in %s, at %s:%d", ap=0xfeffd810, kind=DK_ICE)
    at /vol/gcc/src/hg/trunk/local/gcc/diagnostic.c:1108
#4  0xfded65e8 in internal_error (gmsgid=0xfce827f4 "in %s, at %s:%d")
    at /vol/gcc/src/hg/trunk/local/gcc/diagnostic.c:1434
#5  0xfded7296 in fancy_abort (
    file=0xfcac4170 "/vol/gcc/src/hg/trunk/local/gcc/cgraph.h", line=404, 
    function=0xfcac9a80 <_ZZN11symtab_node3getEPK9tree_nodeE12__FUNCTION__>
"get") at /vol/gcc/src/hg/trunk/local/gcc/diagnostic.c:1500
#6  0xfd7d4d3b in symtab_node::get (decl=0xf8000000)
    at /vol/gcc/src/hg/trunk/local/gcc/tree.h:3502

  decl is

 <error_mark f8000000>

#7  decl_comdat_group(tree_node const*) [clone .cold.496] ()
    at /vol/gcc/src/hg/trunk/local/gcc/tree.c:708
#8  0xfd8ce379 in solaris_define_comdat_signature (slot=0x80b39fc, aux=0x0)
    at /vol/gcc/src/hg/trunk/local/gcc/config/sol2.c:267
#9  0xfd8ce6d7 in hash_table<comdat_entry_hasher,
xcallocator>::traverse_noresize<void*,
&(solaris_define_comdat_signature(comdat_entry**, void*))> (
    argument=0x0, this=<optimized out>)
    at /vol/gcc/src/hg/trunk/local/gcc/config/sol2.c:290
#10 hash_table<comdat_entry_hasher, xcallocator>::traverse<void*,
&(solaris_define_comdat_signature(comdat_entry**, void*))> (argument=0x0, 
    this=<optimized out>) at /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:990
#11 solaris_file_end () at /vol/gcc/src/hg/trunk/local/gcc/config/sol2.c:291
#12 0xfd469dcc in compile_file ()
    at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:606
#13 0xfd46c4f3 in do_compile ()
    at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:2081
#14 toplev::main(int, char**) ()
    at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:2216
#15 0xfcedea7a in gcc::jit::playback::context::compile (this=0xfeffdad0)
    at /vol/gcc/src/hg/trunk/local/gcc/jit/jit-playback.c:1840
#16 0xfced2880 in gcc::jit::recording::context::compile_to_file (
    this=0x8069170, output_kind=GCC_JIT_OUTPUT_KIND_ASSEMBLER, 
    output_path=0x805180c "output-of-test-compile-to-assembler.c.s")
    at /vol/gcc/src/hg/trunk/local/gcc/jit/jit-recording.c:1384
#17 0xfcec6642 in gcc_jit_context_compile_to_file (ctxt=0x8069170, 
    output_kind=GCC_JIT_OUTPUT_KIND_ASSEMBLER, 
    output_path=0x805180c "output-of-test-compile-to-assembler.c.s")
    at /vol/gcc/src/hg/trunk/local/gcc/jit/libgccjit.c:2712
#18 0x080524c9 in test_jit (
    argv0=0xfeffdd3e
"/var/gcc/regression/trunk/11.4-gcc/build.jit/gcc/testsuite/jit/test-compile-to-assembler.c.exe",
user_data=0x0)
    at /vol/gcc/src/hg/trunk/local/gcc/testsuite/jit.dg/harness.h:364
#19 0x080525d9 in main (argc=1, argv=0xfeffdc0c)
    at /vol/gcc/src/hg/trunk/local/gcc/testsuite/jit.dg/harness.h:419

  Haven't yet started debugging how error_mark arrives there.

  When using gas/ld instead, the error isn't present.

* When using as and ld, there's one additional failure:

st-long-names.c.exe.reproducer.c
Input string too long, limit 10240
./test-long-names.c.exe: error: error invoking gcc driver
        FAILED: test-long-names.c.exe iteration 1 of 5: verify_code: result is
NULL
FAIL:  test-long-names.c.exe iteration 1 of 5: verify_code: result is NULL
FAIL: test-long-names.c.exe killed: 7958 exp9 0 0 CHILDKILLED SIGABRT SIGABRT

  The "Input string too long, limit 10240" message is from as.  One could
either
  xfail the test in this case or reduce NAME_LENGTH appropriately.

* In the 32-bit case, two tests FAIL like this:

        PASSED: test-vector-rvalues.cc.exe iteration 1 of 5: verify_vec_code:
fn is non-null
        FAILED: test-vector-rvalues.cc.exe iteration 1 of 5: check_div: actual:
c[i] != expected: a[i] / b[i]
incorrect value

        FAILED: test-vector-rvalues.cc.exe iteration 1 of 5: check_div: actual:
c[i] != expected: a[i] / b[i]
incorrect value

#0  0xfc2cb64d in abort () from /lib/libc.so.1
#1  0x080544b2 in check_div<float __vector(4)>(float __vector(4) const&, float
__vector(4) const&, float __vector(4) const&) (a=..., b=..., c=...)
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/test-vector-rvalues.cc:165

165         CHECK_VALUE (c[i], a[i] / b[i]);
(gdb) p c[i]
$1 = 0.416666657
(gdb) p a[i]
$2 = 5
(gdb) p b[i]
$3 = 12

  probably needs to be CHECK_DOUBLE_VALUE instead

#2  0x08054297 in verify_vec_code<float __vector(4), float>(gcc_jit_context*,
gcc_jit_result*, char const*, void (*)(float __vector(4) const&, float
__vector(4) const&, float __vector(4) const&)) (ctxt=0x806f6b0,
result=0x80c9870, 
    fnname=0x80524f5 "jit_v4f_div", 
    check_cb=0x805440b <check_div<float __vector(4)>(float __vector(4) const&,
float __vector(4) const&, float __vector(4) const&)>)
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/test-vector-rvalues.cc:191
#3  0x08053861 in verify_code (ctxt=0x806f6b0, result=0x80c9870)
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/test-vector-rvalues.cc:210
#4  0x0805323a in test_jit (
    argv0=0xfeffdfc8
"/var/gcc/regression/trunk/11.4-gcc-gas/build/gcc/testsuite/jit/test-vector-rvalues.cc.exe",
user_data=0x0)
    at /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/harness.h:373
#5  0x0805330f in main (argc=1, argv=0xfeffde94)
    at /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/harness.h:419

PASS:  test-vector-rvalues.cc.exe iteration 1 of 5: verify_vec_code: fn is
non-null
FAIL:  test-vector-rvalues.cc.exe iteration 1 of 5: check_div: actual: c
FAIL: test-vector-rvalues.cc.exe killed: 23396 exp9 0 0 CHILDKILLED SIGABRT
SIGABRT

        FAILED: test-vector-types.cc.exe iteration 1 of 5: check_div: actual:
c[i] != expected: a[i] / b[i]
incorrect value

#0  0xfc2cb64d in abort () from /lib/libc.so.1
#1  0x0805427c in check_div<float __vector(4)>(float __vector(4) const&, float
__vector(4) const&, float __vector(4) const&) (a=..., b=..., c=...)
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/test-vector-types.cc:139
#2  0x08054061 in verify_vec_code<float __vector(4)>(gcc_jit_context*,
gcc_jit_result*, char const*, void (*)(float __vector(4) const&, float
__vector(4) const&, float __vector(4) const&)) (ctxt=0x806f470,
result=0x80c5448, 
    fnname=0x8052432 "jit_v4f_div", 
    check_cb=0x80541d5 <check_div<float __vector(4)>(float __vector(4) const&,
float __vector(4) const&, float __vector(4) const&)>)
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/test-vector-types.cc:165
#3  0x08053673 in verify_code (ctxt=0x806f470, result=0x80c5448)
    at
/vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/test-vector-types.cc:184
#4  0x0805315a in test_jit (
    argv0=0xfeffdfd0
"/var/gcc/regression/trunk/11.4-gcc-gas/build/gcc/testsuite/jit/test-vector-types.cc.exe",
user_data=0x0)
    at /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/harness.h:373
#5  0x0805322f in main (argc=1, argv=0xfeffde9c)
    at /vol/gcc/src/hg/trunk/solaris/gcc/testsuite/jit.dg/harness.h:419

  ISTM that check_div needs to use CHECK_DOUBLE_VALUE here.

* libgccjit.so is only built for the default multilib.  If running make check
  across all multilibs, all tests for the non-default multilibs (like the
64-bit
  ones when testing on i386-pc-solaris2.11) will FAIL.  Since one probably 
  doesn't want to build libgccjit.so for those multilibs, too, jit.exp needs
  to skip them to avoid tons of testsuite noise.

Overall, results aren't too bad for a first attempt.

Reply via email to