couchbase / couchbase/fleece

CMake build with GCC on macOS fails

Open
#231 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
338
Forks
35
Avg merge
13h 41m
Merged PRs (30d)
3

Description

I'm trying to build Fleece with GCC 13 on my Mac, just so I can catch more build errors locally before pushing a PR. Unfortunately it doesn't work, because GCC doesn't appear to understand 'modern' Objective-C at all.

Steps to repro

After installing GCC with Homebrew, I just do this before running cmake:

export CC=/opt/homebrew/bin/gcc-13
export CXX=/opt/homebrew/bin/g++-13
Results

It fails with a bunch of instances of this error:

g++-13: error: unrecognized command-line option '-fobjc-arc'; did you mean '-fobjc-gc'?

I modified platform_apple.cmake to set the -fobjc-arc flag only with AppleClang. Then it emits this warning:

/Users/snej/Couchbase/CBL_C/vendor/couchbase-lite-core/vendor/fleece/Fleece/API_Impl/Fleece.cc:36:29: warning: 'visibility' attribute ignored [-Wattributes]
   36 | FLEECE_PUBLIC const FLValue kFLNullValue  = Value::kNullValue;
      |                             ^~~~~~~~~~~~

followed by literally a bajillion errors in the .mm files due to GCC not understanding Obj-C block syntax (^), the nullable keyword, generic interfaces (like @interface NSEnumerator<ObjectType>), and on and on...

Analysis

Looks like we need to skip all the .mm files when building with GCC; that's fine since I don't intend to use the build products, just look for errors before they occur in CI.

Unfortunately I don't know CMake well enough to figure out how to conditionally remove them from platform_apple.cmake. All my attempts have resulted in cryptic errors from the cmake tool.

Contributor guide

No contributing guide indexed for this repository

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 platform_apple.cmake and the GCC 13 reproduction using the CC and CXX values from the issue. Inspect how the .mm files and -fobjc-arc are selected for AppleClang versus GCC; done means the GCC CMake build no longer tries to compile unsupported Objective-C sources while the AppleClang configuration remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, objective-c
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.