dlang-community / setup-dlang

Github action for dlang compiler setup
MIT License
46 stars 14 forks source link

Any idea how to integrate GDC? #35

Open p0nce opened 3 years ago

p0nce commented 3 years ago

Using a recent GDC would be a boon to our linux testing. Any idea how to do it?

PetarKirov commented 3 years ago

setup-dlang is more or less doing what the official install script is doing (only using Typescript + GH Actions builtins, instead of bash).

The main blocker is having prebuilt GDC packages, like LDC and DMD provide. IMO this should be done upstream either by the @D-Programming-GDC or @dlang organizations.

That said, technically nothing prevents someone for setting up a GitHub Action pipeline here that would do the same. Here's a starting point for a CI pipeline: https://github.com/D-Programming-GDC/gcc/blob/5ff6ab4f88164b4c8939a8780da42dc39bd2a7ff/.semaphore/semaphore.yml#L1

p0nce commented 3 years ago

Thanks. Maybe I'm being stupid: is there maybe a way to just invocate sudo apt install gdc in the user Action? Any GDC version would do.

mihails-strasuns commented 3 years ago

If you are fine with any version and only interested in Linux, literally running apt install gdc in your action should do the trick - and take roughly same amount of yml config :)

For setup-dlang there both needs to be some way to switch between version and support for all of Win-Linux-MacOS triplet. It should be possible to do, probably with some enhancements to GDC own CI, but it is a fair bit of work, much more than was needed for dmd/ldc, so it was not originally implemented.

p0nce commented 3 years ago

Fine! Thanks :)

mihails-strasuns commented 3 years ago

I think it would be better to keep this ticket open - both because it is a necessary feature request and because the same question is likely to come up again. I can create a new one if you prefer of course.

Geod24 commented 3 years ago

We could just mention in the README how to use GDC.

mihails-strasuns commented 3 years ago

Do you have any best practice suggestions? (other than apt install when applicable)

p0nce commented 3 years ago

apt install doesn't actually work in Gitub Actions for GDC.

image

But installing dub or ldc removes GDC: image

So I haven't found a way to support GDC properly... Any idea? Would need both DUB and GDC ideally.

mihails-strasuns commented 3 years ago

It may be a time to ask @ibuclaw for suggestions :)

p0nce commented 3 years ago

Mmmm, I follow the suggestions in the debian thread and install DUB from Github instead. This file allows to dub test with GDC:

name: gdc
on: [push, pull_request]

jobs:
    test:
        name: Dub Tests
        strategy:
            matrix:
                os: [ubuntu-20.04]
                dc: 
                    - ldc-latest 

        runs-on: ${{ matrix.os }}
        steps:
            - uses: actions/checkout@v2

            - name: Install D compiler
              uses: dlang-community/setup-dlang@v1
              with:
                  compiler: ${{ matrix.dc }}

            - name: Install DUB
              run: |
                  wget https://github.com/dlang/dub/releases/download/v1.23.0/dub-v1.23.0-linux-x86_64.tar.gz
                  tar xvf dub-v1.23.0-linux-x86_64.tar.gz

            - name: Install libcurl
              run: sudo apt install libcurl4-gnutls-dev

            - name: Install GDC
              run: sudo apt install gdc              

            - name: Vanilla unittest
              run: ./dub test -a x86_64 --compiler gdc -v

Not optimal but works for this single purpose.

ibuclaw commented 3 years ago

It may be a time to ask @ibuclaw for suggestions :)

I only see that the package maintainers have shot themselves in both feet.

  1. By making gdc and ldc conflict (did ldc install module sources to /usr/include/d on 18.04?)
  2. By insisting on using shared libraries by default when the phobos ABI is so unstable, building in a different path changes symbol names (yes, the debian/ubuntu builders use a generated /buildd path, so each minor version update probably requires all downstream packages to be rebuilt).
SingingBush commented 3 years ago

I was able to use gdc on ubuntu-latest with this change: https://github.com/mbierlee/poodinis/pull/38/commits/6e25ca74fd7516efec48a6c3df92f99f5c296a42

essentially you need something like:

jobs:
  # On Ubuntu we can use GDC (so keep working for D version 2.076)
  gdc-latest:
    name: GDC on Ubuntu
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Install DMD (so dub is available)
        uses: dlang-community/setup-dlang@v1
        with:
          compiler: dmd-latest

      - name: Install GDC
        run: |
          sudo apt-get update
          sudo apt-get install gdc -y
          gdc --version

      - name: Build library
        env:
          DC: gdc
        run: dub build --compiler=gdc --build=release
p0nce commented 2 years ago

FWIW I can test both GDC 10 and GDC 12 in GH actions: https://github.com/AuburnSounds/intel-intrinsics/tree/master/.github/workflows

Geod24 commented 2 years ago

Likewise: https://github.com/dlang/dub/pull/2324 Note that I added support for dub: version in this action, so you can simplify your configuration.

andrey-zherikov commented 2 years ago

Can it be as simple as this?

      - name: Install D compiler
        uses: dlang-community/setup-dlang@v1
        with:
          compiler: gdc-latest
Geod24 commented 2 years ago

This won't work currently. But yes, it would be good to make it work.

p0nce commented 2 years ago

Unrelated? The godbolt DMD compiler are a bit old. I don't think you can test on the newest DMD.

andrey-zherikov commented 2 years ago

This won't work currently. But yes, it would be good to make it work.

As I see in compiler.ts, it's a matter of figuring out the URL for a specific GDC version, isn't it?. Is there an issue with this?

SingingBush commented 2 years ago

updated example for multiple gdc versions:

## On Ubuntu we can use GDC. The compatibility of gdc is:
##   gcc gdc-10  -> D 2.076 (the default on Ubuntu 20.04 (ubuntu-latest), also available on 22.04)
##   gcc gdc-11  -> D 2.076 (requires Ubuntu 22.04)
##   gcc gdc-12  -> D 2.100 (requires Ubuntu 22.04)
## Note that Github's ubuntu-latest isn't actually the latest release. It's currently set to "ubuntu-20.04" despite github having "ubuntu-22.04" runners (similar situation with macos-latest)
## For this reason it's best to use ubuntu-22.04

jobs:
  test-gdc:
    name: ${{ matrix.compiler }} on ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-22.04 ]
        compiler: [ gdc-10, gdc-11, gdc-12 ]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2

      - name: Install DMD (so dub is available)
        uses: dlang-community/setup-dlang@v1
        with:
          compiler: dmd-latest

      - name: Install dependencies on Ubuntu
        if: startsWith(matrix.os, 'ubuntu')
        run: sudo apt-get update && sudo apt-get install libev-dev libevent-dev libsqlite3-dev -y

      - name: Install ${{ matrix.compiler }}
        run: |
          sudo apt-get update
          sudo apt-get install ${{ matrix.compiler }} -y

      - name: Show version
        run: |
          ${{ matrix.compiler }} --version
          dub --version

      - name: Build library
        env:
          DC: ${{ matrix.compiler }}
        run: dub build --compiler=${{ matrix.compiler }} --build=release
schveiguy commented 1 year ago

Just ran into this... Any help would be appreciated: https://github.com/dlang/undeaD/pull/56

WebFreak001 commented 1 year ago

SingingBush's example is the current way how to do it. We don't have it in setup-dlang yet because it isn't supported on platforms other than ubuntu-2022.

What we could do is just running apt install on ubuntu and only allow that as the only supported GDC OS on setup-dlang for now though.

schveiguy commented 1 year ago

OK, so given that I already have a matrix of oses and compilers, how do I skip the invalid combinations? Or do I just make a new yml file?

WebFreak001 commented 1 year ago

you can use exclude to exclude all the things that match (entire combinations or also just partial matches iirc)

See https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#excluding-matrix-configurations

andrey-zherikov commented 1 year ago

What's about adding configuration?

      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
        dc: [dmd-latest, ldc-latest]
        include:
          - os: ubuntu-latest
            dc: gdc-latest
WebFreak001 commented 1 year ago

you need to separate the installation step like for example D-Scanner does it then: https://github.com/dlang-community/D-Scanner/blob/5a53c538d0aa832f03840840271b6631fbbfc53d/.github/workflows/default.yml#L78-L89

schveiguy commented 1 year ago

where does DC get defined? I got the workflow running, it installs gdc (and dub from dmd), and then runs dub with dmd, because apparently DC is set to dmd.

WebFreak001 commented 1 year ago

oh yeah setup-dlang sets DC - you can manually set it (it's just an environment variable) - or use it to only install dub.

schveiguy commented 1 year ago

will setup-dlang set DC if I set it first? (hoping it doesn't)

WebFreak001 commented 1 year ago

yes, it does so here: https://github.com/dlang-community/setup-dlang/blob/43589c229861e1720e187a344c67dad1d9eefe4c/src/main.ts#L64

andrey-zherikov commented 1 year ago

you need to separate the installation step like for example D-Scanner does it then: https://github.com/dlang-community/D-Scanner/blob/5a53c538d0aa832f03840840271b6631fbbfc53d/.github/workflows/default.yml#L78-L89

Can setup-dlang take care of this? Even if it's restricted to ubuntu only, this would be very helpful.

schveiguy commented 1 year ago

So the way I had to do this kinda sucks: https://github.com/dlang/undeaD/blob/d9a6eaad18e5c64bf36609158f1c257f1162c071/.github/workflows/main.yml

I'd like to do it better, or have some of this taken care of without so many manual if conditions. Almost think it would have been better to run a separate task.

But it did work!

mihails-strasuns commented 1 year ago

Can setup-dlang take care of this?

I think this was the original reasoning: I wanted to be able to just specify platform/compiler/version matrix and have things "just work". As GDC was (and looks like still is) only available through a distro package install, it was not fitting that pattern. What if you want to test a different GDC version? apt install gdc is great for development but as much for testing coverage, should I maintain a list of older packages to directly download? Have a separate CI to build all relevant GDC versions from source and provide binaries?

So I ended up embracing laziness as a virtue and just ignored the whole thing in a hope things will become more obvious to some point. Which clearly has not happened :) Saved me from a headache though.

tl; dr is "yes, setup-dlang absolutely can take care of this but maybe it can also do better and the right thing is not 100% obvious for GDC".

schveiguy commented 1 year ago

Yeah, we really should make this work seamlessly. Especially as gdc has now joined the other compilers into the post-2.076 front end realm. People will expect to be able to test against various gdc releases.

What pre-built artifacts are there for gdc? Is there a way we can host them? I know windows is a specific problem, as there is no pre-built binaries that people maintain. downloads.dlang.org should probably be doing it. @ibuclaw is there a way we can fit this into the release process for gdc/dmd?

mihails-strasuns commented 1 year ago

https://gdcproject.org/downloads#binary-releases implies this was an intentional decision to stop providing binaries, although it is not clear if motivation was to reduce CI load or @ibuclaw simply wanted it to be this way.

WebFreak001 commented 6 months ago

let's just implement it internally by doing apt install and only being supported on linux for now