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 building ponyc on DragonFly BSD #3676

Merged
merged 2 commits into from
Feb 20, 2021
Merged

Conversation

mneumann
Copy link
Contributor

  • LLVM on DragonFly does not ship with libatomic; it has to be installed
    manually via pkg ins cxx_atomics.

  • Note that ponyc has to be build with gcc as stdatomic.h from
    cxx_atomics fails to work with LLVM (in a prior attempt I tried to
    compile ponyc with LLVM).

  • Pass -latomic to the linker when targeting DragonFly. Also add
    -L/usr/local/cxx_atomics as search path.

  • Until a new version of google/benchmark is released, you'll need
    the patch from this PR and apply it to gbenchmark to build
    ponyc.

Superseeds: #3654 (which on it's own, never worked)

* LLVM on DragonFly does not ship with `libatomic`; it has to be installed
  manually via `pkg ins cxx_atomics`.

* Note that ponyc has to be build with gcc as `stdatomic.h` from
  `cxx_atomics` fails to work with LLVM (in a prior attempt I tried to
  compile ponyc with LLVM).

* Pass `-latomic` to the linker when targeting DragonFly. Also add
  `-L/usr/local/cxx_atomics` as search path.

* Until a new version of `google/benchmark` is released, you'll need
  [the patch from this PR][1] and apply it to `gbenchmark` to build
  ponyc.

[1]: google/benchmark#1058
@SeanTAllen
Copy link
Member

Does you gcc comment mean it wouldn't build with clang on dragonfly? Is there clang for dragonfly?

@mneumann
Copy link
Contributor Author

@SeanTAllen Yes, it does not build with clang. If you try to (by setting env CC=clang10 CXX=clang++10), you'll get tons of these error messages:

/home/mneumann/Dev/ponyc/src/libponyrt/actor/actor.c:32:19: error: address argument to atomic operation must be a pointer to a
      trivially-copyable type ('_Atomic(unsigned char) *' invalid)
  uint8_t flags = atomic_load_explicit(&actor->flags, memory_order_relaxed);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/cxx_atomics/stdatomic.h:138:5: note: expanded from macro 'atomic_load_explicit'
    __atomic_load (__atomic_load_ptr, &__atomic_load_tmp, (MO));        \
    ^              ~~~~~~~~~~~~~~~~~
/home/mneumann/Dev/ponyc/src/libponyrt/actor/actor.c:32:11: error: initializing 'uint8_t' (aka 'unsigned char') with an expression of
      incompatible type 'typeof (*__atomic_load_ptr)' (aka '_Atomic(unsigned char)')
  uint8_t flags = atomic_load_explicit(&actor->flags, memory_order_relaxed);
          ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This seems to be an issue with clang itself. Does this work on FreeBSD?

@mneumann
Copy link
Contributor Author

@SeanTAllen It actually compiles with LLVM/clang, but not with the cxx_atomics package. The problem is that the clang/llvm port on DragonFly does not ship with the libatomic.a and stdatomic.h files (FreeBSD does). Someone on dragonflybsd #irc then suggested to use the cxx_atomics library instead. The stdatomic.h file of cxx_atomics is from the GCC project ("This file is part of GCC"), and it does not work with LLVM. LLVM itself ships with it's own version of that header file, just not on DragonFly.

I once got it to compile with LLVM (https://github.com/mneumann/ponyc/tree/dragonfly-fix-compile), but that was rather a hack.
IIRC clang automatically added "-latomic" when linking, even though, it did not use any functions from libatomic (on x86). GCC on the other hand requires -latomic to be specified explicitly.

I will ask the maintainer of the cxx_atomics port, if he can also include the LLVM version of stdatomic.h, which would solve the problem.

Base automatically changed from master to main February 8, 2021 23:02
@SeanTAllen
Copy link
Member

Thanks @mneumann.

@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Feb 16, 2021
@SeanTAllen SeanTAllen changed the title Make ponyc work on DragonFly Fix ponyc compilation on DragonFly BSD Feb 16, 2021
@ponylang-main
Copy link
Contributor

Hi @mneumann,

The changelog - fixed 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 3676.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.

@SeanTAllen
Copy link
Member

@mneumann if you have time to add release notes to this, that would be great. otherwise i will merge later this week and add release notes myself.

@SeanTAllen
Copy link
Member

Release notes added.

@SeanTAllen SeanTAllen changed the title Fix ponyc compilation on DragonFly BSD Fix building ponyc on DragonFly BSD Feb 20, 2021
@SeanTAllen SeanTAllen merged commit 37273da into ponylang:main Feb 20, 2021
@SeanTAllen
Copy link
Member

Thanks @mneumann

github-actions bot pushed a commit that referenced this pull request Feb 20, 2021
github-actions bot pushed a commit that referenced this pull request Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants