Skip to content

-framework argument not handled correctly #13204

Closed

Description

We appear to be mishandling -F, -iframework and -iframeworkwithsysroot compiler arguments, assuming them to be variations of the -framework argument. Rather, these arguments specify where to search for frameworks specified by a -framework argument. These args set up a set of search paths similar to include paths but that apply only to resolving subsequent -framework args on the command line. Also, a -framework argument is intended to be a framework 'name', not a path.

The order of arguments is significant. A -framework preceding a -F does not consider the search path the -F adds. Similarly, if -iframeworkwithsysroot is specified, that applies only to subsequent -framework arg.

It doesn't help that man clang on macOS provides misleading information about -F, associating it specifically with framework include paths (not frameworks themselves), only differing from the description of -I by one word, and not referring to -framework at all.

-I<directory> Add the specified directory to the search path for include files.
-F<directory> Add the specified directory to the search path for framework include files.

Currently, the C/C++ Extension will search directories specified by any of these args (in addition to the default framework paths from a compiler query), for every framework within them, adding all of them to the browse path and IntelliSense configs. It looks like this behavior would be correct, to support sub-frameworks, if applied only to frameworks and not framework search paths.

Most users probably haven't noticed an issue, as this would pick up a superset of frameworks. Though, issues could potentially arise due to IntelliSense picking up headers with conflicting names from incorrect frameworks.

Activity

  1. Colengms commented on Jan 28, 2025

    @Colengms
    ContributorAuthor

    It's possible some users are currently benefiting from having all system framework include paths automatically added. If this is 'fixed', those users would have to add the system frameworks they want to use to their configuration using -framework args, analogous to having to do so on a compiler command line.

  2. Colengms commented on Jan 29, 2025

    @Colengms
    ContributorAuthor

    The macFrameworkPaths field unfortunately seems to encode the misconception about these arguments, referring only to paths. For now, we could continue to support this field as indicating either a full path to a framework or a framework name (the later intended to be resolved against system search paths, and any additional framework search paths from compilerArgs, when the configuration is processed).

  3. Colengms commented on Jan 29, 2025

    @Colengms
    ContributorAuthor

    Continuing to dig deeper, what we're doing now appears to be mostly correct.

    "-framework" is primarily for linking purposes. It would be impossible to 'use' a framework without linking to it (unless it's a header-only framework?), but it's not strictly required at compile time. Clang does allow references to frameworks not specified with "-framework" in #include statements (framework include statements are special *), making the "framework search paths" interesting to us (and not "-framework"). The only issue here is that we currently look at "-framework" arguments, looking for search paths. Instead we can ignore "-framework" entirely, as it's effectively only useful at link time.

    * (i.e. #include <OpenGLES/ES2/gl.h>, mapping to OpenGLES.framework/Headers/ES2/gl.h).

    Repurposing this issue to track removing existing handling of "-framework" in favor of ignoring/stripping that argument.

  4. changed the title [-]macOS frameworks not handled correctly[/-] [+]`-framework` argument not handled correctly[/+] on Jan 29, 2025
  5. moved this from In progress to Pull Request in cpptoolson Jan 30, 2025
  6. moved this from Pull Request to Done in cpptoolson Feb 4, 2025
  7. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Feb 7, 2025
  8. locked and limited conversation to collaborators on Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Feature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions