Bug 100218 - [Clover] Handle -g passed as a compile option
Summary: [Clover] Handle -g passed as a compile option
Alias: None
Product: Mesa
Classification: Unclassified
Component: Gallium/StateTracker/Clover (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
Depends on:
Blocks: 99553
  Show dependency treegraph
Reported: 2017-03-15 17:47 UTC by Vedran Miletić
Modified: 2019-09-18 17:56 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description Vedran Miletić 2017-03-15 17:47:49 UTC
Clover uses clang::CompilerInvocation::CreateFromArgs() which is roughly equivalent to clang -cc1 frontend and does not support GCC-like options, including -g, which is sometimes passed by OpenCL programs. Section 5.6.3 of OpenCL 1.1 spec [1] says: "This specification defines a standard set of options that must be supported by an OpenCL compiler when building program executables online or offline.  These may be extended by a set of vendor-or platform-specific options."

Since -g is not mentioned in the spec, we can either:
1) Fail with "Clover does not support -g", which is what we do now but could be made more explicit.
2) Ignore it, that is s/-g//.
3) Figure out how to enable it and then s/-g/-whatever/ before passing it to clang.

[1] https://www.khronos.org/registry/OpenCL/specs/opencl-1.1.pdf
Comment 1 Aaron Watry 2017-03-22 16:34:38 UTC
Just thought I'd chime in here.

I don't necessary try to use '-g' when compiling cl kernels/programs in clover, but I have been poking at getting some programs working that relying on the CL1.2 'static' keyword...

I had been trying to enable that at one point by setting CLOVER_EXTRA_BUILD_OPTIONS to include "-Dcl_clang_storage_class_specifiers", as I found that manually invoking clang with that define set allowed me to build some of the kernels I was working with (e.g. blender cycles, along with some stuff from hcc and others).

But no matter what I set, including specifying -cl-std=1.2 (after bumping the supported version in [platform|device].cpp, it always seemed like the clang invocation was ignoring all of the indicated build options.

We may end up having to do number 3 anyway, as I feel like we're losing the user-specified compiler arguments somehow.

But there's always the possibility that I'm doing it wrong, so take this with a grain of salt.
Comment 2 Jan Vesely 2017-03-22 20:55:53 UTC
Opencl defines are handled by clang and should not be set on command line, they are also target specific (although cl_storage_class_specifiers is enabled on all targets).

you can get the list of defines by running:
clang -dM -E -x cl -cl-std=cl1.1  - < /dev/null

for turks GPU:clang -cc1 -dM -E -x cl  -cl-std=cl1.1 -triple r600-unknown-unknown -target-cpu turks - < /dev/null
Comment 3 GitLab Migration User 2019-09-18 17:56:18 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/139.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.