← All tasks
cppYosysHQ/yosys #5930Not a task: not reproduced

CMake migration regressions for macOS + Homebrew

envgap__YosysHQ__yosys-5930

01 / FAILURE SIGNATURE

As reported upstream

CMake Error in /Users/kumom/yosys/build/CMakeFiles/CMakeScratch/TryCompile-aLZzTg/CMakeLists.txt:
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
017c99be5b2f1b3a42b3ab9bf5201ad871be8d44
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

YosysHQ/yosys #5930 · read the original issue
### Version

Yosys 0.64+308 (git sha1 78e05dfb0-dirty, Release, AppleClang /usr/bin/c++ 21.0.0.21000101)

### On which OS did this happen?

macOS

### Reproduction Steps

After the CMake migration (a727e7f6e), building Yosys on macOS with a standard Homebrew toolchain hits several regressions compared to the old Makefile. 

Tested on: macOS 26, Apple Clang 21, Homebrew at `/opt/homebrew`.
  
### 1. pkg-config picks broken Apple .pc shims for keg-only libraries
  
`pkg_config_import(libffi)` fails because `pkg-config` returns an include path inside the SDK that no longer exists:

`/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/ffi`
  
CMake's `try_compile` in `cmake/PkgConfig.cmake:25` then errors out with "Imported target ... includes non-existent path." Same problem hits `libedit`. Root cause: Homebrew auto-injects shim `.pc` files at `/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/<version>/` that describe Apple's bundled libraries at SDK paths that may not ship the headers on current macOS releases.
  
The old Makefile (lines 130-151) avoided this by prepending Homebrew's keg-only `lib/pkgconfig/` directories to `PKG_CONFIG_PATH`. The new `CMakeLists.txt` does not.

**The old Makefile had a parallel `else ifneq port` branch. I do not use MacPorts so my first patch will not include this part.**
  
### 2. Bison detection picks Apple's /usr/bin/bison 2.3
  
`find_package(BISON)` finds `/usr/bin/bison` (Apple-bundled, version 2.3 from 2008). However `frontends/verilog/verilog_parser.y:36` requires Bison 3.6+ (`%require "3.6"`), so parser generation fails later in the build. The old Makefile prepended `$(brew --prefix)/opt/bison/bin` to PATH; the new build does not.

### 3. `ENABLE_EDITLINE` default changed from off to on

Old `Makefile` (line 15): `ENABLE_EDITLINE := 0`
New `CMakeLists.txt` (line 50): `option(YOSYS_WITHOUT_EDITLINE ... OFF)`

The semantics flipped: `editline` is now enabled by default, where previously it was disabled by default and readline was used. This interacts with issue (1): users without `libedit` brew-installed now hit the broken-shim error, where before they were unaffected.
  
May be intentional, so I include relevant fix in my coming PR because that's how I resolved the issue on my machine.

### Expected Behavior

Successful build.

### Actual Behavior

For `pkg-config` related issues, I got
```
  -- The C compiler identification is AppleClang 14.0.3.14030022                                                                                               
  -- The CXX compiler identification is AppleClang 14.0.3.14030022                                                                                             
  -- Detecting C compiler ABI info                                                                                                                             
  -- Detecting C compiler ABI info - done                                                                                                                      
  -- Check for working C compiler: /usr/bin/cc - skipped                                                                                                       
  -- Detecting C compile features                                                                                                                              
  -- Detecting C compile features - done                                                                                                                       
  -- Detecting CXX compiler ABI info                                                                                                                           
  -- Detecting CXX compiler ABI info - done                                                                                                                    
  -- Check for working CXX compiler: /usr/bin/c++ - skipped                                                                                                    
  -- Detecting CXX compile features                                                                                                                            
  -- Detecting CXX compile features - done                                                                                                                     
  -- Found FLEX: /usr/bin/flex (found version "2.6.4")                                                                                                         
  -- Found BISON: /usr/bin/bison (found version "2.3")                                                                                                         
  -- Found Python3: /Users/kumom/miniforge3/bin/python3.13 (found suitable version "3.13.12", minimum required is "3.7") found components: Interpreter         
  -- Looking for glob                                                                                                                                          
  -- Looking for glob - found                                                                                                                                  
  -- Looking for system                                                                                                                                        
  -- Looking for system - found                                                                                                                                
  -- Looking for popen                                                                                                                                         
  -- Looking for popen - found                                                                                                                                 
  -- Performing Test HAVE_PTHREAD_CREATE                                                                                                                       
  -- Performing Test HAVE_PTHREAD_CREATE - Success                                                                                                             
  -- Looking for dlopen                                                                                                                                        
  -- Looking for dlopen - found                                                                                                                                
  -- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "2.5.1")                                                                                     
  -- Checking for module 'zlib'                                                                                                                                
  --   Found zlib, version 1.2.12                                                                                                                              
  -- Checking for module 'libffi'                                                                                                                              
  --   Found libffi, version 3.4-rc1                                                                                                                           
  CMake Error in /Users/kumom/yosys/build/CMakeFiles/CMakeScratch/TryCompile-aLZzTg/CMakeLists.txt:                                                            
    Imported target "PkgConfig::libffi" includes non-existent path                                                                                             
                                                                                                                                                               
      "/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/ffi"                                                                                  
                                                                                                                                                               
    in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:                                                                                           
                                                                                                                                                               
    * The path was deleted, renamed, or moved to another location.                                                                                             
                                                                                                                                                               
    * An install or uninstall procedure did not complete successfully.                                                                                         
                                                                                                                                                               
    * The installation package was faulty and references files it does not                                                                                     
    provide.                                                                                                                                                   
                                                                                                                                                               
                                                                                                                                                               
                                                                                                                                                               
  CMake Error in /Users/kumom/yosys/build/CMakeFiles/CMakeScratch/TryCompile-aLZzTg/CMakeLists.txt:                                                            
    Imported target "PkgConfig::libffi" includes non-existent path                                                                                             
                                                                                                                                                               
      "/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/ffi"                                                                                  
                                                                                                                                                               
    in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:                                                                                           
                                                                                                                                                               
    * The path was deleted, renamed, or moved to another location.                                                                                             
                                                                                                                                                               
    * An install or uninstall procedure did not complete successfully.                                                                                         
                                                                                                                                                               
    * The installation package was faulty and references files it does not                                                                                     
    provide.                                                                                                                                                   
                                                                                                                                                               
                                                                                                                                                               
                                                                                                                                                               
  CMake Error at cmake/PkgConfig.cmake:25 (try_compile):                                                                                                       
    Failed to generate test project build system.                                                                                                              
  Call Stack (most recent call first):                                                                                                                         
    CMakeLists.txt:212 (pkg_config_import)
```

For `editline` related issue, I got
```
CMake Error in /Users/kumom/yosys/build/CMakeFiles/CMakeScratch/TryCompile-3eEyTQ/CMakeLists.txt:                                                            
    Imported target "PkgConfig::editline" includes non-existent path                                                                                           
                                                                                                                                                               
      "/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/editline"                                                                             
                                                                                                                                                               
    in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:                                                                                           
                                                                                                                                                               
    * The path was deleted, renamed, or moved to another location.                                                                                             
                                                                                                                                                               
    * An install or uninstall procedure did not complete successfully.                                                                                         
                                                                                                                                                               
    * The installation package was faulty and references files it does not                                                                                     
    provide.                                                                                                                                                   
                                                                                                                                                               
                                                                                                                                                               
                                                                                                                                                               
  CMake Error in /Users/kumom/yosys/build/CMakeFiles/CMakeScratch/TryCompile-3eEyTQ/CMakeLists.txt:                                                            
    Imported target "PkgConfig::editline" includes non-existent path                                                                                           
                                                                                                                                                               
      "/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/editline"                                                                             
                                                                                                                                                               
    in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:                                                                                           
                                                                                                                                                               
    * The path was deleted, renamed, or moved to another location.                                                                                             
                                                                                                                                                               
    * An install or uninstall procedure did not complete successfully.                                                                                         
                                                                                                                                                               
    * The installation package was faulty and references files it does not                                                                                     
    provide.                                                                                                                                                   
                                                                                                                                                               
                                                                                                                                                               
                                                                                                                                                               
  CMake Error at cmake/PkgConfig.cmake:25 (try_compile):                                                                                                       
    Failed to generate test project build system.                                                                                                              
  Call Stack (most recent call first):                                                                                                                         
    CMakeLists.txt:243 (pkg_config_import)                                                                                                                     
                                                                                                                                                               
                                                                                                                                                               
  -- Configuring incomplete, errors occurred!
```

I didn't encounter `bison` related problems actually. Claude found potential problems from my `cmake -B build` output and patched the problem preemptively.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]