Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 862
    • Issues 862
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 41
    • Merge requests 41
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Merge requests
  • !979

Experimental clang-cl support

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Chun-wei Fan requested to merge clang-cl-support into master Jul 09, 2019
  • Overview 5
  • Commits 1
  • Pipelines 3
  • Changes 9

Hi,

This adds preliminary support for building GLib with clang-cl, which is a variation of CLang/LLVM that tries to pretend itself as the MSVC compiler. This, as a result, updates the build system to assume that clang-cl is a msvc-style build for most things, but also has the advantage to enable g_autoptr.

This also updates the glib/gmacros.h header so that

-We use the GCC-style deprecation annotations, not MSVC-style, so that things won't break on clang-cl builds.

-Check for the __clang__ macro to enable the GCC- and CLang-only g_autoptr support, which can be used by clang-cl to build items that use it against the GTK stack that is built by real MSVC. Please note that clang-cl understandably does not define __GNUC__ but instead defines _MSC_VER.

This will depend on MR !980 (merged), as the updates in glib/gmacros.h there are needed for this to work and the updates there will make the GLib headers more usable even if building against a real MSVC-built GTK stack with clang-cl.

Note that this does depend on a recent Visual Studio and Microsoft Windows SDK (2017+) in order to work, so this is likely to be less well-supported than real MSVC, at least for a forseeable amount of time, meaning that this should be considered experimental.

For records, since we are requiring Meson 0.48.0, we couldn't use cc.get_argument_syntax, which looks cleaner. This will also depend on Meson to be updated to fix detection on strcasecmp(), strncasecmp() and stpcpy() on clang-cl (see https://github.com/mesonbuild/meson/issues/5628)

With blessings, thank you!

Edited Mar 19, 2021 by Philip Withnall
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: clang-cl-support