1

Is there a brew --with-debug-flag-set package style command available to get brew to build a package that includes debug information.

Specifically, I would like clisp to be built this way so that disassemble works in the repl.

I imagine something along the lines of:

brew install clisp --with-debug

or somesuch.

1

According to Mike McQuaid (Lead maintainer of Homebrew) this is not possible.

  • Not directly, but the compile flags should allow it. I've added a basic example in a separate reply. :) – tresf Jun 20 '18 at 15:07
1

A brew formula is a Ruby (.rb) file that contains the compile options inside. Homebrew's brew install|reinstall allows specifying a URL instead of a formula name, so compile flags can be added to an online copy of the formula and hosted on a service like gist.github.com.

Here's an example ruby file that has an overridden compile option.

def install
   args = std_cmake_args

   # OVERRIDE: Force cmake to use debug flags
   args << "-DCMAKE_BUILD_TYPE=Debug"

   system "cmake", ".", *args
end

std_cmake_args, defined in Homebrew's interneal formula.rb is a variable internal to all Homebrew cmake formula and provides sane defaults to each cmake build prior to adding additional arguments.

This example uses cmake, each project will have its own compiler tools and thus potentially different technique(s) for adding compile flags. For example, to tell cmake to use Debug flags, it's args << "-DCMAKE_BUILD_TYPE=Debug"

Once these changes have been made to the .rb file and hosted online, you can reinstall the package with the new options using the --build-from-source command line option.

brew reinstall --build-from-source https://<path to formula>.rb
  1. WARNING: If using gist.github.com, note that the "Raw" version is the URL that you want. If not, it'll try to install the HTML (e.g. code preview) of the page, which won't work. :)

  2. WARNING: Remember, this will reinstall the specified package in the Homebrew directory with debug flags, so the old "release" or "optimized" build will not longer be available. So please remember to reinstall the non-debug version using the standard brew install technique once troubleshooting has been completed or else you'll have a debug version of a library on your computer until it's manually updated. :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .