ocaml / ocaml/dune

pkg-config not resolved on windows with dune configurator

Open
#4,130 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

configurator windows
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Expected Behavior

Once pkg-config --libs libpng returns the value get it and return from C.Pkg_config.get

Actual Behavior

C.Pkg_config.get on windows always return None

Reproduction

  1. Use windows server for example in GitHub actions
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest]
        # os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/setup-node@v2
        with:
          node-version: '13'
      - uses: actions/checkout@v2.3.2

      - name: Install libpng
        run: |
          C:\vcpkg\vcpkg install libpng
          ls C:\vcpkg\packages\libpng_x86-windows\lib\pkgconfig
          $env:PKG_CONFIG_PATH += 'C:\vcpkg\packages\libpng_x86-windows\lib\pkgconfig'
          pkg-config --libs libpng # returns correct flags
        #..prepare your env 
       - name: Run dune
         run: |
          dune build -p myprojec

With a simple dune configurator executable

(executable
 (name discover)
 (libraries dune-configurator))

And discover.ml code

module C = Configurator.V1

let () =
C.main ~name:"odiff-c-lib-package-resolver" (fun c ->
let default : C.Pkg_config.package_conf =
  { libs   = ["libpng"]
  ; cflags = []
  }
in
let conf =
  match C.Pkg_config.get c with
  | None -> default
  | Some pc ->
     match (C.Pkg_config.query pc ~package:"libpng") with
     | None -> default
     | Some deps -> deps
in

Printf.printf "Resolved c flags %s" (String.concat "" conf.cflags);
Printf.printf "\nResolved c libs %s" (String.concat "" conf.libs);

C.Flags.write_sexp "c_flags.sexp"         conf.cflags;
C.Flags.write_sexp "c_library_flags.sexp" conf.libs) 

Observe that conf.cflags and conf.libs are always empty

Specifications

  • Version of dune (output of dune --version): 2.7.1
  • Version of ocaml (output of ocamlc --version): 4.11.1
  • Operating system (distribution and version): Windows Server 2019 (easy to reproduce on Github actions)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dune-configurator implementation behind C.Pkg_config.get and reproduce the issue using the discover.ml example on Windows Server 2019 or windows-latest. Compare the result with the pkg-config command shown in the GitHub Actions workflow; done means C.Pkg_config.get and query return the libpng flags instead of empty values on Windows.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, ocaml
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.