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

Any idea how to integrate GDC? #35

Open
p0nce opened this issue Dec 29, 2020 · 35 comments
Open

Any idea how to integrate GDC? #35

p0nce opened this issue Dec 29, 2020 · 35 comments
Labels
enhancement New feature or request

Comments

@p0nce
Copy link

p0nce commented Dec 29, 2020

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

@PetarKirov
Copy link
Member

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
Copy link
Author

p0nce commented Dec 30, 2020

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
Copy link
Collaborator

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
Copy link
Author

p0nce commented Dec 30, 2020

Fine! Thanks :)

@p0nce p0nce closed this as completed Dec 30, 2020
@mihails-strasuns mihails-strasuns added the enhancement New feature or request label Dec 30, 2020
@mihails-strasuns
Copy link
Collaborator

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.

@PetarKirov PetarKirov reopened this Dec 31, 2020
@Geod24
Copy link
Member

Geod24 commented Dec 31, 2020

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

@mihails-strasuns
Copy link
Collaborator

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

@p0nce
Copy link
Author

p0nce commented Jan 2, 2021

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

  • On Ubuntu 20.04, the linker output an error that is:
    dub: symbol lookup error: dub: undefined symbol: _D3std3net4curl4HTTP9__mixin376onSendMFNdDFAvZmZv
    Similar to that thread: https://forum.dlang.org/post/[email protected]

  • Downgrading to Ubuntu 18.04, installing GDC removes dub and ldc packages.

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
Copy link
Collaborator

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

@p0nce
Copy link
Author

p0nce commented Jan 3, 2021

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
Copy link
Contributor

ibuclaw commented Jan 3, 2021

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
Copy link

I was able to use gdc on ubuntu-latest with this change: mbierlee/poodinis@6e25ca7

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
Copy link
Author

p0nce commented Sep 7, 2022

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

@Geod24
Copy link
Member

Geod24 commented Sep 7, 2022

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

@andrey-zherikov
Copy link

Can it be as simple as this?

      - name: Install D compiler
        uses: dlang-community/setup-dlang@v1
        with:
          compiler: gdc-latest

@Geod24
Copy link
Member

Geod24 commented Sep 8, 2022

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

@p0nce
Copy link
Author

p0nce commented Sep 8, 2022

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

@andrey-zherikov
Copy link

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
Copy link

SingingBush commented Sep 9, 2022

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
Copy link

Just ran into this... Any help would be appreciated: dlang/undeaD#56

@WebFreak001
Copy link
Member

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
Copy link

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
Copy link
Member

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
Copy link

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
Copy link
Member

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
Copy link

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
Copy link
Member

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
Copy link

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

@WebFreak001
Copy link
Member

yes, it does so here:

core.exportVariable("DC", descr.name);

@andrey-zherikov
Copy link

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
Copy link

schveiguy commented Jun 9, 2023

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
Copy link
Collaborator

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
Copy link

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
Copy link
Collaborator

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants