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

Experimental support for LLVM 4.0.1 (#1592) and 5.0.0. #2303

Merged
merged 1 commit into from
Nov 25, 2017

Conversation

chalcolith
Copy link
Member

This change includes the following:

  • Compiler code updates for changes to the LLVM 4.0.0 and 5.0.0 API.
  • Updates to Type-Based Alias Analysis metadata format for LLVM 4.0.0 and up.

@chalcolith chalcolith added the do not merge This PR should not be merged at this time label Oct 25, 2017
AllocaInst* replace = new AllocaInst(builder.getInt8Ty(), int_size, "",
begin);
#else
AllocaInst* replace = new AllocaInst(builder.getInt8Ty(),
(unsigned int)int_size->getZExtValue(), "", begin);
Copy link
Member

Choose a reason for hiding this comment

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

The new signature of the array AllocaInst constructor is

explicit AllocaInst(Type *Ty, unsigned AddrSpace,
                    Value *ArraySize = nullptr,
                    const Twine &Name = "",
                    Instruction *InsertBefore = nullptr);

This means that this is currently using the non-array constructor which isn't taking a size, and is passing the intended size as the address space. This call should instead be

AllocaInst* replace = new AllocaInst(builder.getInt8Ty(), 0, int_size, "", begin);

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, fixed now.

README.md Outdated
@@ -250,6 +250,8 @@ Pony requires one of the following versions of LLVM:
- 3.7.1
Copy link
Member

Choose a reason for hiding this comment

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

The unsupported version should be removed

README.md Outdated
@@ -497,7 +499,7 @@ make default_pic=true

You need to have the development versions of the following installed:

* LLVM 3.7.1, 3.8.1, or 3.9.1
* LLVM 3.7.1, 3.8.1, 3.9.1, 4.0.1, or 5.0.0
Copy link
Member

Choose a reason for hiding this comment

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

unsupported versions should be removed

README.md Outdated
@@ -565,7 +567,7 @@ Please note that on 32-bit X86, using LLVM 3.7.1 or 3.8.1 on FreeBSD currently p
## Building on Mac OS X
[![Linux and OS X](https://travis-ci.org/ponylang/ponyc.svg?branch=master)](https://travis-ci.org/ponylang/ponyc)

You'll need llvm 3.7.1, 3.8.1 or 3.9.1 and the pcre2 library to build Pony. You can use either homebrew or MacPorts to install your dependencies. Please note that llvm 3.9.1 is not available via homebrew. As such, the instructions below install 3.8.1
You'll need llvm 3.7.1, 3.8.1, 3.9.1, 4.0.1, or 5.0.0 and the pcre2 library to build Pony. You can use either homebrew or MacPorts to install your dependencies. Please note that llvm 3.9.1 is not available via homebrew. As such, the instructions below install 3.8.1
Copy link
Member

Choose a reason for hiding this comment

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

unsupposerted versions

README.md Outdated
@@ -565,7 +567,7 @@ Please note that on 32-bit X86, using LLVM 3.7.1 or 3.8.1 on FreeBSD currently p
## Building on Mac OS X
[![Linux and OS X](https://travis-ci.org/ponylang/ponyc.svg?branch=master)](https://travis-ci.org/ponylang/ponyc)

You'll need llvm 3.7.1, 3.8.1 or 3.9.1 and the pcre2 library to build Pony. You can use either homebrew or MacPorts to install your dependencies. Please note that llvm 3.9.1 is not available via homebrew. As such, the instructions below install 3.8.1
You'll need llvm 3.7.1, 3.8.1, 3.9.1, 4.0.1, or 5.0.0 and the pcre2 library to build Pony. You can use either homebrew or MacPorts to install your dependencies. Please note that llvm 3.9.1 is not available via homebrew. As such, the instructions below install 3.8.1
Copy link
Member

Choose a reason for hiding this comment

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

a later version of llvm is available on OSX via homebrew. this should be updated to use that.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is the latest version available via homebrew?

@@ -113,6 +113,66 @@ matrix:
- ICC1=gcc-6
Copy link
Member

Choose a reason for hiding this comment

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

3.7.1 and 3.8.1 tests should be removed.

Copy link
Member

Choose a reason for hiding this comment

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

We won't be removing these yet because LLVM >= 4 is still in the "experimental" stage.

I added a note to #2371 to remove these when that is resolved.

@chalcolith
Copy link
Member Author

I have removed builds and references to 3.7.1 and 3.8.1.

In the README, I'm not sure if replacing '3.8' or '3.9' with '5.0' in the names of various packages is actually valid.

@chalcolith
Copy link
Member Author

Note that this PR contains a workaround for the LLVM issue, not an actual fix.

@chalcolith chalcolith dismissed Praetonus’s stale review October 26, 2017 20:55

I have made the requested change.

@chalcolith
Copy link
Member Author

Does anybody with access to MacOS know what happened to the 4.0.1 builds?

@SeanTAllen
Copy link
Member

@kulibali you want to install llvm@4 via brew

@winksaville
Copy link
Contributor

I've done some tests on my Arch Linux system after applying this PR to master and found it can pass 965 tests of the 1064 tests in libponyc.tests when I exclude tests with:

./build/debug/libponyc.tests --gtest_filter=*-Codegen*:IftypeTest.*:BareTest.Codegen_Bare*:BareTest.BareFunction*:ReachTest.IsectHasSubtypes*:CompilerSerialisationTest.*

It turns out the compiler fails on the very first set of test cases in CodegenOptimisationTest.*

$ ./build/debug/libponyc.tests
[==========] Running 1064 tests from 43 test cases.
[----------] Global test environment set-up.
[----------] 2 tests from CodegenOptimisationTest
[ RUN      ] CodegenOptimisationTest.MergeSendMessageReordering
[       OK ] CodegenOptimisationTest.MergeSendMessageReordering (55 ms)
[ RUN      ] CodegenOptimisationTest.MergeSendCrossMessaging
Segmentation fault (core dumped)

In CodegenOptimisationTest there are only two tests and if you run them together it usually fails:

$ ./build/debug/libponyc.tests --gtest_filter=CodegenOptimisationTest.*
Note: Google Test filter = CodegenOptimisationTest.*
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from CodegenOptimisationTest
[ RUN      ] CodegenOptimisationTest.MergeSendMessageReordering
[       OK ] CodegenOptimisationTest.MergeSendMessageReordering (63 ms)
[ RUN      ] CodegenOptimisationTest.MergeSendCrossMessaging
Segmentation fault (core dumped)

But not always:

$ ./build/debug/libponyc.tests --gtest_filter=CodegenOptimisationTest.*
Note: Google Test filter = CodegenOptimisationTest.*
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from CodegenOptimisationTest
[ RUN      ] CodegenOptimisationTest.MergeSendMessageReordering
[       OK ] CodegenOptimisationTest.MergeSendMessageReordering (61 ms)
[ RUN      ] CodegenOptimisationTest.MergeSendCrossMessaging
[       OK ] CodegenOptimisationTest.MergeSendCrossMessaging (29 ms)
[----------] 2 tests from CodegenOptimisationTest (90 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (94 ms total)
[  PASSED  ] 2 tests.

Also it has "allways" works if I run the tests one at a time:

$ ./build/debug/libponyc.tests --gtest_filter=CodegenOptimisationTest.MergeSendMessageReordering
Note: Google Test filter = CodegenOptimisationTest.MergeSendMessageReordering
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from CodegenOptimisationTest
[ RUN      ] CodegenOptimisationTest.MergeSendMessageReordering
[       OK ] CodegenOptimisationTest.MergeSendMessageReordering (61 ms)
[----------] 1 test from CodegenOptimisationTest (61 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (65 ms total)
[  PASSED  ] 1 test.
wink@wink-desktop:~/foss/pony/ponyc (test-pr2303-llvm5)
$ ./build/debug/libponyc.tests --gtest_filter=CodegenOptimisationTest.MergeSendCrossMessaging
Note: Google Test filter = CodegenOptimisationTest.MergeSendCrossMessaging
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from CodegenOptimisationTest
[ RUN      ] CodegenOptimisationTest.MergeSendCrossMessaging
[       OK ] CodegenOptimisationTest.MergeSendCrossMessaging (27 ms)
[----------] 1 test from CodegenOptimisationTest (27 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (30 ms total)
[  PASSED  ] 1 test.

If I use coredumpctl gdb to see what happened:

$ ./build/debug/libponyc.tests --gtest_filter=CodegenOptimisationTest.*
Note: Google Test filter = CodegenOptimisationTest.*
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from CodegenOptimisationTest
[ RUN      ] CodegenOptimisationTest.MergeSendMessageReordering
[       OK ] CodegenOptimisationTest.MergeSendMessageReordering (61 ms)
[ RUN      ] CodegenOptimisationTest.MergeSendCrossMessaging
Segmentation fault (core dumped)
wink@wink-desktop:~/foss/pony/ponyc (test-pr2303-llvm5)
$ coredumpctl gdb
           PID: 22341 (libponyc.tests)
           UID: 1000 (wink)
           GID: 100 (users)
        Signal: 11 (SEGV)
     Timestamp: Wed 2017-11-15 14:20:28 PST (17s ago)
  Command Line: ./build/debug/libponyc.tests --gtest_filter=CodegenOptimisationTest.*
    Executable: /home/wink/foss/pony/ponyc/build/debug/libponyc.tests
 Control Group: /user.slice/user-1000.slice/session-c2.scope
          Unit: session-c2.scope
         Slice: user-1000.slice
       Session: c2
     Owner UID: 1000 (wink)
       Boot ID: 07291a8f430b4bda94cbfe3da0bb379c
    Machine ID: 8f80fd742eae4659baed812cd07a9439
      Hostname: wink-desktop
       Storage: /var/lib/systemd/coredump/core.libponyc\x2etests.1000.07291a8f430b4bda94cbfe3da0bb379c.22341.1510784428000000.lz4
       Message: Process 22341 (libponyc.tests) of user 1000 dumped core.
                
                Stack trace of thread 22341:
                #0  0x000055e5c69a4e6a n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #1  0x000055e5c69a4f94 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #2  0x000055e5c699a00e n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #3  0x000055e5c699b686 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #4  0x000055e5c6a4c84d n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #5  0x000055e5c699954f n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #6  0x000055e5c699a3d0 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #7  0x000055e5c6a38c8f n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #8  0x000055e5c6a3c135 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #9  0x000055e5c69e0f8f n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #10 0x000055e5c69e0fed n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #11 0x000055e5c6a376a7 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #12 0x000055e5c68fd9c9 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #13 0x000055e5c68fc5f5 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #14 0x000055e5c68521b3 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #15 0x000055e5c69ccc74 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #16 0x000055e5c69c7cb7 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #17 0x000055e5c69ad952 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #18 0x000055e5c69ae1a2 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #19 0x000055e5c69ae818 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #20 0x000055e5c69b5652 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #21 0x000055e5c69cde35 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #22 0x000055e5c69c8af3 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #23 0x000055e5c69b423a n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #24 0x000055e5c68fe74b n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #25 0x000055e5c68fe648 n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)
                #26 0x00007f7810086f6a __libc_start_main (libc.so.6)
                #27 0x000055e5c6851cba n/a (/home/wink/foss/pony/ponyc/build/debug/libponyc.tests)

GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/wink/foss/pony/ponyc/build/debug/libponyc.tests...done.
[New LWP 22341]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `./build/debug/libponyc.tests --gtest_filter=CodegenOptimisationTest.*'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055e5c69a4e6a in pool_get (pool=0x7f78156161d8, index=0) at src/libponyrt/mem/pool.c:801
801	    thread->pool = p->next;
(gdb) bt
#0  0x000055e5c69a4e6a in pool_get (pool=0x7f78156161d8, index=0) at src/libponyrt/mem/pool.c:801
#1  0x000055e5c69a4f94 in ponyint_pool_alloc (index=0) at src/libponyrt/mem/pool.c:845
#2  0x000055e5c699a00e in ponyint_serialise_object (ctx=0x7fff47ce24f0, p=0x7f780fbdc780, t=0x55e5c6dc88a0 <ast_signature_pony>, mutability=0)
    at src/libponyrt/gc/serialise.c:124
#3  0x000055e5c699b686 in pony_traceknown (ctx=0x7fff47ce24f0, p=0x7f780fbdc780, t=0x55e5c6dc88a0 <ast_signature_pony>, m=0) at src/libponyrt/gc/trace.c:114
#4  0x000055e5c6a4c84d in ast_signature_serialise_trace (ctx=0x7fff47ce24f0, object=0x7f780fbdc180) at src/libponyc/ast/ast.c:1734
#5  0x000055e5c699954f in ponyint_gc_handlestack (ctx=0x7fff47ce24f0) at src/libponyrt/gc/gc.c:619
#6  0x000055e5c699a3d0 in pony_serialise (ctx=0x7fff47ce24f0, p=0x7f780fbd4ac0, t=0x55e5c6dc8620 <package_group_signature_pony>, out=0x7fff47ce24d0, 
    alloc_fn=0x55e5c6a38b96 <s_alloc_fn>, throw_fn=0x55e5c6a38bb4 <s_throw_fn>) at src/libponyrt/gc/serialise.c:225
#7  0x000055e5c6a38c8f in package_group_signature (group=0x7f780fbd4ac0) at src/libponyc/pkg/package.c:1578
#8  0x000055e5c6a3c135 in program_signature (program=0x7f780fc24cc0) at src/libponyc/pkg/program.c:288
#9  0x000055e5c69e0f8f in ast_passes (astp=0x7fff47ce2738, options=0x55e5c7b988e0, last=PASS_ALL) at src/libponyc/pass/pass.c:259
#10 0x000055e5c69e0fed in ast_passes_program (ast=0x7f780fc24cc0, options=0x55e5c7b988e0) at src/libponyc/pass/pass.c:271
#11 0x000055e5c6a376a7 in program_load (path=0x7f780fc24500 "prog", opt=0x55e5c7b988e0) at src/libponyc/pkg/package.c:933
#12 0x000055e5c68fd9c9 in PassTest::build_package (this=0x55e5c7b988d0, pass=0x55e5c6ab217c "ir", 
    src=0x55e5c6ab2248 "actor A\n  be m(a: A) => None\nactor Main\n  new create(env: Env) =>\n    test(A, A)\n  be test(a1: A, a2: A) =>\n    a1.m(a2)\n    a2.m(a1)", package_name=0x55e5c6acc340 "prog", check_good=true, expected_errors=0x0, resume=false) at test/libponyc/util.cc:476
#13 0x000055e5c68fc5f5 in PassTest::test_compile (this=0x55e5c7b988d0, 
    src=0x55e5c6ab2248 "actor A\n  be m(a: A) => None\nactor Main\n  new create(env: Env) =>\n    test(A, A)\n  be test(a1: A, a2: A) =>\n    a1.m(a2)\n    a2.m(a1)", pass=0x55e5c6ab217c "ir") at test/libponyc/util.cc:328
#14 0x000055e5c68521b3 in CodegenOptimisationTest_MergeSendCrossMessaging_Test::TestBody (this=0x55e5c7b988d0) at test/libponyc/codegen_optimisation.cc:60
#15 0x000055e5c69ccc74 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (object=0x55e5c7b988d0, 
    method=&virtual testing::Test::TestBody(), location=0x55e5c6aec6a3 "the test body") at lib/gtest/src/gtest.cc:2078
#16 0x000055e5c69c7cb7 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0x55e5c7b988d0, 
    method=&virtual testing::Test::TestBody(), location=0x55e5c6aec6a3 "the test body") at lib/gtest/src/gtest.cc:2114
#17 0x000055e5c69ad952 in testing::Test::Run (this=0x55e5c7b988d0) at lib/gtest/src/gtest.cc:2150
#18 0x000055e5c69ae1a2 in testing::TestInfo::Run (this=0x55e5c7a0d8d0) at lib/gtest/src/gtest.cc:2326
#19 0x000055e5c69ae818 in testing::TestCase::Run (this=0x55e5c7a0d750) at lib/gtest/src/gtest.cc:2444
#20 0x000055e5c69b5652 in testing::internal::UnitTestImpl::RunAllTests (this=0x55e5c7a0d3f0) at lib/gtest/src/gtest.cc:4315
#21 0x000055e5c69cde35 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x55e5c7a0d3f0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x55e5c69b5392 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x55e5c6aeceb0 "auxiliary test code (environments or event listeners)") at lib/gtest/src/gtest.cc:2078
#22 0x000055e5c69c8af3 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x55e5c7a0d3f0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x55e5c69b5392 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x55e5c6aeceb0 "auxiliary test code (environments or event listeners)") at lib/gtest/src/gtest.cc:2114
#23 0x000055e5c69b423a in testing::UnitTest::Run (this=0x55e5c6de13c0 <testing::UnitTest::GetInstance()::instance>) at lib/gtest/src/gtest.cc:3926
#24 0x000055e5c68fe74b in RUN_ALL_TESTS () at lib/gtest/gtest/gtest.h:2288
#25 0x000055e5c68fe648 in main (argc=1, argv=0x7fff47ce3da8) at test/libponyc/util.cc:635

We see that the SIGSEGV happens in src/libponyrt/mem/pool.c:801:

$ cat --number src/libponyrt/mem/pool.c
...
   792	static void* pool_get(pool_local_t* pool, size_t index)
   793	{
   794	  // Try per-size thread-local free list first.
   795	  pool_local_t* thread = &pool[index];
   796	  pool_global_t* global = &pool_global[index];
   797	  pool_item_t* p = thread->pool;
   798	
   799	  if(p != NULL)
   800	  {
   801	    thread->pool = p->next;
   802	    thread->length--;
   803	    return p;
   804	  }
...

If I look at *thread and *p we see that thread->pool and p are pointing at apparently bad memory:

(gdb) print *thread
$1 = {pool = 0x900000008, length = 640, start = 0x7f780f99a9a0 "", end = 0x7f780f99ac00 ""}
(gdb) print *p
Cannot access memory at address 0x900000008

Is there any other information needed or something else I can do to track down the problem?

@chalcolith
Copy link
Member Author

You also need to build the stdlib tests (ponyc packages/stdlib) in release mode and run them. On Ubuntu the stdlib executable segfaults immediately.

winksaville added a commit to winksaville/ponyc-rpm-bin that referenced this pull request Nov 19, 2017
This installs ponyc using `makepkg -si` from the release .rpm
files on [bintray](https://bintray.com/pony-language/ponyc-rpm).

The current ponyc package installed via pacman is not compatible with
LLVM5 and fails, see Arch Linux bug
[55170](https://bugs.archlinux.org/task/55170) archlinux bug.
It is also not possible to build ponyc from source for
the same reason. [Issue 2303](ponylang/ponyc#2303)
is tracking the problem.
@SeanTAllen
Copy link
Member

given the problems with getting pony installed on rolling distros like Arch, thoughts on merging this and isolating and performance hits to LLVM 4 and 5 and we can have a big shiny warning that there are definitely performance issues with the bug workaround?

@chalcolith
Copy link
Member Author

I need to update this PR to deal with the changes from #2334.

@chalcolith
Copy link
Member Author

Ok, the branch is all rebased and updated.

Some informal benchmarks, running time stdlib doesn't seem to be appreciably affected"

Test | LLVM | Times (s) |   |   |   |   | Average (s)
-- | -- | -- | -- | -- | -- | -- | --
stdlib | 3.9.1 | 1.613 | 1.612 | 1.568 | 1.596 | 1.571 | 1.592
stdlib | 4.0.1 | 1.522 | 1.561 | 1.539 | 1.568 | 1.499 | 1.5378
stdlib | 5.0.0 | 1.633 | 1.519 | 1.565 | 1.513 | 1.538 | 1.5536

@winksaville
Copy link
Contributor

@kulibali I've tried to build the packages/stdlib tests but the compilation fails:

$ ./build/debug/ponyc -d -s --checktree --verify packages/stdlib
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building packages/stdlib -> /home/wink/prgs/pony/ponyc/packages/stdlib
Building ponytest -> /home/wink/prgs/pony/ponyc/packages/ponytest
...
Verifying
Writing ./stdlib.o
Linking ./stdlib
./stdlib.o:stdlib:function ssl__SSLInit_box__init_o: error: undefined reference to 'SSL_load_error_strings'
./stdlib.o:stdlib:function ssl__SSLInit_box__init_o: error: undefined reference to 'SSL_library_init'
./stdlib.o:stdlib:function ssl__SSLInit_box__init_o: error: undefined reference to 'CRYPTO_num_locks'
./stdlib.o:stdlib:function ssl__SSLInit_box__init_o: error: undefined reference to 'CRYPTO_set_locking_callback'
./stdlib.o:stdlib:function ssl__SSLInit_val__init_o: error: undefined reference to 'SSL_load_error_strings'
./stdlib.o:stdlib:function ssl__SSLInit_val__init_o: error: undefined reference to 'SSL_library_init'
./stdlib.o:stdlib:function ssl__SSLInit_val__init_o: error: undefined reference to 'CRYPTO_num_locks'
./stdlib.o:stdlib:function ssl__SSLInit_val__init_o: error: undefined reference to 'CRYPTO_set_locking_callback'
./stdlib.o:stdlib:function crypto_Digest_ref_final_o: error: undefined reference to 'EVP_MD_CTX_cleanup'
./stdlib.o:stdlib:function crypto_Digest_ref_sha512_o: error: undefined reference to 'EVP_MD_CTX_create'
./stdlib.o:stdlib:function crypto_Digest_ref_md5_o: error: undefined reference to 'EVP_MD_CTX_create'
collect2: error: ld returned 1 exit status
Warning: environment variable $CC undefined, using cc as the linker
Error:
unable to link: cc -o ./stdlib -O3 -march=native -mcx16 -latomic -fuse-ld=gold ./stdlib.o -L"/home/wink/prgs/pony/ponyc/build/debug/" -Wl,-rpath,"/home/wink/prgs/pony/ponyc/build/debug/" -L"/home/wink/prgs/pony/ponyc/build/debug/../../packages" -Wl,-rpath,"/home/wink/prgs/pony/ponyc/build/debug/../../packages" -Wl,--start-group -l"rt" -l"crypto" -l"pcre2-8" -l"ssl" -Wl,--end-group  -lpthread -lponyrt-pic -ldl -lm -Wl,--export-dynamic-symbol=__PonyDescTablePtr -Wl,--export-dynamic-symbol=__PonyDescTableSize

I did some searching and I'm guessing the problem is that Arch is using libssl.so.1.1 and SSL_library_init and the other undefines is no longer available, see openssl library initialization.

The problem might be resvoled by passing OPENSSL_API_COMPAT and OPENSSL_MIN_API with an appropriate value such as 0x10000000L or 0x00908000L.

If someone can tell me how I might pass defines when building the standard library I can give it a try.

@SeanTAllen SeanTAllen closed this Nov 21, 2017
@SeanTAllen SeanTAllen reopened this Nov 21, 2017
@SeanTAllen
Copy link
Member

@winksaville there’s an issue re OpenSSL dependency. This would be best discussed there.

@winksaville
Copy link
Contributor

I hacked together a change that did allow the stdlib test to work with Arch Linux running LLVM5 and OpenSSL 1.1 on top of these changes. See this post on #1838. Note, the libponyc.tests still fail as I mentioned above.

@Praetonus
Copy link
Member

thoughts on merging this and isolating and performance hits to LLVM 4 and 5 and we can have a big shiny warning that there are definitely performance issues with the bug workaround?

I'd personally be more comfortable with merging this without the workaround and warn that the support is experimental. The reason is that I don't think that the workaround fixes every case of the bug, given the LLVM change that introduced it.

@chalcolith
Copy link
Member Author

From sync: I will do the following:

  • Make the default in the Makefile and wscript 3.9.1, and add a warning if building with 4 or 5.
  • Double-check that the LLVM workaround does not appear in 3.9.1, and add a comment to clearly indicate it in the code.
  • Add a note in the README noting that 4 and 5 are only experimentally supported and will have performance problems and maybe other crash bugs.
  • Create a new issue to actually fix LLVM 4 and 5.

This change includes the following:

- Compiler code updates for changes to the LLVM 4.0.0 and 5.0.0 API.
- Updates to Type-Based Alias Analysis metadata format for LLVM 4.0.0 and up.

Note that this code contains a workaround for a problem with hoisting
loads of stack-allocated references (see ponylang#2303, ponylang#2061, ponylang#1592), and should be
considered experimental.  Do not use LLVM 4 or 5 for critical production
builds.
@chalcolith chalcolith added changelog - added Automatically add "Added" CHANGELOG entry on merge and removed do not merge This PR should not be merged at this time labels Nov 24, 2017
@chalcolith
Copy link
Member Author

Ok, I have made the changes I note above, and squashed and rebased. This should be ready to go.

@jemc
Copy link
Member

jemc commented Nov 25, 2017

My only remaining doubt is that this really increases our build load on Travis CI - I'm wondering if we should consider removing 4.0.1 from the build matrix and depend on our testing of 5.0.0 until the #2371 is resolved and we remove the old version of LLVM from the build matrix.

However, I'm not going to hold up this PR on that account - we can consider doing it as a followup.

Great work here, everyone!

@jemc jemc changed the title Update the Pony compiler to be able to use LLVM 4.0.1 (#1592) and 5.0.0. Experimental support for LLVM 4.0.1 (#1592) and 5.0.0. Nov 25, 2017
@jemc jemc merged commit 7531c99 into ponylang:master Nov 25, 2017
ponylang-main added a commit that referenced this pull request Nov 25, 2017
@chalcolith chalcolith deleted the llvm500 branch January 26, 2018 03:36
lukecheeseman pushed a commit to lukecheeseman/ponyc that referenced this pull request Feb 17, 2018
This commit adds support for LLVM >= 4, but disables some stack allocation performance optimizations to do so. As such, we've marked this support as experimental until the optimization can be reinstated.
lukecheeseman pushed a commit to lukecheeseman/ponyc that referenced this pull request May 28, 2018
This commit adds support for LLVM >= 4, but disables some stack allocation performance optimizations to do so. As such, we've marked this support as experimental until the optimization can be reinstated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - added Automatically add "Added" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants