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

Update to LLVM 12.0.1 #3745

Merged
merged 1 commit into from
Jul 14, 2021
Merged

Update to LLVM 12.0.1 #3745

merged 1 commit into from
Jul 14, 2021

Conversation

chalcolith
Copy link
Member

Supersedes #3731

  • Update the LLVM submodule to llvmorg-12.0.0
  • Update the JIT code to work with LLVM 12.
  • Update custom optimizations to work with LLVM 12.
  • Move old JIT and optimization code to separate files for historical reference
  • Update handling LLVM library dependencies:
    • Consolidate LLVM library configuration in the root CMakeLists.txt file.
    • Deprecate the llvm_config cmake macro in favour of using individual components with llvm_map_components_to_libnames.
  • Include the in-progress work on Mac M1:
    • Update CMakeLists.txt to require C++14 (LLVM now does).
    • Add missing header to cpu.c that is required on Apple M1.

@chalcolith chalcolith added triggers release Major issue that when fixed, results in an "emergency" release do not merge This PR should not be merged at this time changelog - changed Automatically add "Changed" CHANGELOG entry on merge labels Apr 20, 2021
@ponylang-main
Copy link
Contributor

Hi @kulibali,

The changelog - changed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 3745.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@redvers
Copy link
Contributor

redvers commented Apr 27, 2021

I am able to build this using nix somewhat cleanly, except I appear to fail the same test-stdlib-release as some of the CI below:

Building serialise -> /home/red/projects/pony/ponyc/packages/serialise
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Verifying
PHI node operands are not the same type as the result!
  %108 = phi i8* [ %7, %99 ], [ %23, %105 ]
Call parameter type does not match function signature!
  %5 = getelementptr inbounds [32 x i1], [32 x i1]* %4, i64 0, i64 0
 i8*  call void @llvm.memcpy.p0i8.p0i8.i64(i1* nonnull align 8 dereferenceable(5) %5, i8* nonnull align 8 dereferenceable(5) getelementptr inbounds ([6 x i8], [6 x i8]* @9904, i64 0, i64 0), i64 5, i1 false) #2
Call parameter type does not match function signature!
  %5 = getelementptr inbounds [32 x i1], [32 x i1]* %4, i64 0, i64 0
 i8*  %8 = call i32 @bcmp(i8* nonnull dereferenceable(5) getelementptr inbounds ([6 x i8], [6 x i8]* @9904, i64 0, i64 0), i1* nonnull dereferenceable(5) %5, i64 5) #2
Stored value type does not match pointer operand type!
  store i8 102, i1* %6, align 8
 i1Stored value type does not match pointer operand type!
  store i8 97, i1* %19, align 1
 i1Stored value type does not match pointer operand type!
  store i8 108, i1* %20, align 2
 i1Stored value type does not match pointer operand type!
  store i8 115, i1* %21, align 1
 i1Stored value type does not match pointer operand type!
  store i8 101, i1* %22, align 4
 i1Call parameter type does not match function signature!

etc...

@redvers
Copy link
Contributor

redvers commented Apr 27, 2021

The build initially failed as nix configures warnings to be errors by default.

The specific build error I got was this:

In file included from /nix/store/pclcc5kl1bkkns8410f6l0dhrnmxll7x-glibc-2.32-37-dev/include/string.h:519,
                 from /home/red/projects/pony/ponyc/src/ponyc/main.c:15:
In function ‘strncat’,
    inlined from ‘main’ at /home/red/projects/pony/ponyc/src/ponyc/main.c:92:5:
/nix/store/pclcc5kl1bkkns8410f6l0dhrnmxll7x-glibc-2.32-37-dev/include/bits/string_fortified.h:122:10: warning: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
  122 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/red/projects/pony/ponyc/src/ponyc/main.c: In function ‘main’:
/home/red/projects/pony/ponyc/src/ponyc/main.c:92:5: note: length computed here
   92 |     strncat((char*)opt.all_args, argv[i], strlen(argv[i]));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... which I believe refers to this:

https://github.com/ponylang/ponyc/blob/llvm1200/src/ponyc/main.c#L92

@chalcolith
Copy link
Member Author

I have narrowed the LLVM problem to the HeapToStack pass.

@redvers
Copy link
Contributor

redvers commented Apr 27, 2021

I'd got it down as far as not being present in a debug compile so was about to start chewing down the Optimization path.

I doubt I would have the skills yet to get to that level of detail.

I shall wander into the wilderness and start prepping a (nixpkgs) build job for this new branch.

Thanks!

@chalcolith chalcolith force-pushed the llvm1200 branch 2 times, most recently from bbe0d17 to 2a46c40 Compare May 1, 2021 04:35
@chalcolith
Copy link
Member Author

This program will reproduce the behaviour:


use "serialise"

actor _EmptyActor

class _HasActor
  let x: _EmptyActor = _EmptyActor

actor Main
  new create(env: Env) =>
    try
      let qwe: _HasActor ref = _HasActor
      let auth = SerialiseAuth(env.root as AmbientAuth)
      let ser = Serialised(auth, qwe)?

      env.out.print("succeeded")
    else
      env.out.print("ELSE")
    end

@SeanTAllen
Copy link
Member

@kulibali reproduce what behavior?

@chalcolith
Copy link
Member Author

The Serialised constructor will eventually call ponyint_serialise_actor(), which calls a lambda that calls pony_error(). The call to _Unwind_RaiseException() in pony_error returns with error code _URC_FAILURE, and control never reaches the personality function ponyint_personality_v0.

@chalcolith
Copy link
Member Author

Sorry -- I mean the 32-bit ARM failures.

@chalcolith
Copy link
Member Author

There is some mention of problems with exception handling on ARM https://stackoverflow.com/questions/51673343/clang-with-libc-exceptions

I haven't had time to investigate further.

@chalcolith
Copy link
Member Author

Here is a stacktrace from 32-bit arm:

#0  __libc_do_syscall ()
    at ../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:44
#1  0xb6dfcee6 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2  0xb6dfdbee in __GI_abort () at abort.c:89
#3  0x0001ce10 in pony_error ()
    at /home/gordon/Dev/Pony/ponyc_llvm1200/src/libponyrt/lang/posix_except.c:41
#4  0x00013ad4 in serialise_$2$6_apply_o ()
    at /home/gordon/Dev/Pony/ponyc_llvm1200/packages/serialise/serialise.pony:105
#5  0x0001c38e in ponyint_serialise_actor (ctx=0xb6dd6e44, actor=0xb3dd6800)
    at /home/gordon/Dev/Pony/ponyc_llvm1200/src/libponyrt/gc/serialise.c:144
#6  0x0001cd18 in pony_traceknown (ctx=0xb6dd6e44, p=0xb3dd6800, t=0x30c10, 
    m=2) at /home/gordon/Dev/Pony/ponyc_llvm1200/src/libponyrt/gc/trace.c:112
#7  0x0001368c in _HasActor_Trace ()
#8  0x0001b7c6 in ponyint_gc_handlestack (ctx=0xb6dd6e44)
    at /home/gordon/Dev/Pony/ponyc_llvm1200/src/libponyrt/gc/gc.c:669
#9  0x0001c4fc in pony_serialise (ctx=0xb6dd6e44, p=0xb6dd0520, t=0x0, 
    out=0xb6dd0560, alloc_fn=0x15264 <serialise_$2$5_apply_oZo>, 
    throw_fn=0x13ac4 <serialise_$2$6_apply_o>)
    at /home/gordon/Dev/Pony/ponyc_llvm1200/src/libponyrt/gc/serialise.c:217
#10 0x00013b74 in serialise_Serialised_ref_create_ooo (this=0xb6dd0540, 

@chalcolith
Copy link
Member Author

Per today's sync we will disable the 32-bit ARM tests for the time being.

@chalcolith
Copy link
Member Author

I have rebased on main and squashed. This should be ready to merge after the next release.

@chalcolith chalcolith marked this pull request as ready for review July 13, 2021 19:26
@chalcolith chalcolith requested a review from a team July 13, 2021 19:26
@chalcolith chalcolith changed the title WIP: Update to LLVM 12.0.0 Update to LLVM 12.0.0 Jul 13, 2021
@chalcolith chalcolith changed the title Update to LLVM 12.0.0 Update to LLVM 12.0.1 Jul 13, 2021

Updated the vendored LLVM submodule to tag `llvmorg-12.0.1`, and updated the build system, code generation, and JIT code to work with LLVM 12.

Disabled 32-bit ARM cross-compilation tests pending fixes for 32-bit ARM and M1.
Copy link
Member

Choose a reason for hiding this comment

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

I dont think this is release note worthy.

Are we basically saying though that we are dropping 32-bit ARM support? I believe so, so we should so that.

Copy link
Member

Choose a reason for hiding this comment

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

updated

@SeanTAllen SeanTAllen requested a review from a team July 13, 2021 19:36
@SeanTAllen
Copy link
Member

@kulibali if you dont get to it before me, i can update the release notes this evening.

- Update the LLVM submodule to `llvmorg-12.0.0`
- Update the JIT code to work with LLVM 12.
- Update custom optimizations to work with LLVM 12.
- Move old JIT and optimization code to separate files for historical reference
- Update handling LLVM library dependencies:
  - Consolidate LLVM library configuration in the root `CMakeLists.txt` file.
  - Deprecate the `llvm_config` cmake macro in favour of using individual components with `llvm_map_components_to_libnames`.
- Include the in-progress work on Mac M1:
  - Update CMakeLists.txt to require C++14 (LLVM now does).
  - Add missing header to cpu.c that is required on Apple M1.
- Fixes #1930
@SeanTAllen
Copy link
Member

I updated the release notes.

@SeanTAllen SeanTAllen merged commit a76e8f1 into main Jul 14, 2021
@SeanTAllen SeanTAllen deleted the llvm1200 branch July 14, 2021 00:06
github-actions bot pushed a commit that referenced this pull request Jul 14, 2021
github-actions bot pushed a commit that referenced this pull request Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - changed Automatically add "Changed" CHANGELOG entry on merge do not merge This PR should not be merged at this time triggers release Major issue that when fixed, results in an "emergency" release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants