Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Valgrind does not compile on OSX 1.9 Mavericks #23660

Closed
spajus opened this issue Oct 27, 2013 · 20 comments
Closed

Valgrind does not compile on OSX 1.9 Mavericks #23660

spajus opened this issue Oct 27, 2013 · 20 comments

Comments

@spajus
Copy link

spajus commented Oct 27, 2013

I know this is probably not the right place to start since the problem is not directly related to Homebrew, but though to share the issue here upfront as it will be acted upon faster.

Valgrind does not have compile options for OSX 1.9 yet, so I've modified configure.ac to mimic OSX 1.8 when compiling on 1.9.
It got me though configure step, but I finally got stuck when running make:

18 warnings and 4 errors generated.
make[3]: *** [m_syswrap/libcoregrind_amd64_darwin_a-syswrap-darwin.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Configure line was:

./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/valgrind/3.8.1 --enable-only64bit --build=amd64-darwin

See the Gist for configure.ac patch and full make output

Ideas how to move it further?

@mistydemeo
Copy link
Member

Have you reported this to the Valgrind developers?

@spajus
Copy link
Author

spajus commented Oct 27, 2013

I would start there if they were on GitHub, but since they use mailing lists and bugzilla, I thought it would be simpler to start a discussion here and submit the solution to Valgrind community later.

@spajus
Copy link
Author

spajus commented Oct 27, 2013

Registered an issue in Valgrind's bugzilla: https://bugs.kde.org/show_bug.cgi?id=326724

@drodriguez
Copy link
Contributor

I got it to compile (from trunk) using the patches in https://gist.github.com/drodriguez/d8713b063c7d1dfd5f46 but it still doesn't work. The patches simply comment out part of the code related to two constants that seems to have dissapear in Maverics (/usr/include/sys/fcntl.h has the following comment 46,47 used to be F_READBOOTSTRAP and F_WRITEBOOTSTRAP).

Anyway, as I said, it doesn’t work, I get the following when testing with ls -l:

UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!UNKNOWN fcntl 61!eq_SyscallStatus:
  {78 0 43}
  {78 0 40}

valgrind: m_syswrap/syswrap-main.c:381 (Bool eq_SyscallStatus(SyscallStatus *, SyscallStatus *)): the 'impossible' happened.

There should be some work in trunk for 10.8 according to this email http://article.gmane.org/gmane.comp.debugging.valgrind/13280 but even in trunk things do not work.

So, no luck at all.

@jacknagel
Copy link
Contributor

We've updated to valgrind 3.9.0 in the meantime, but since it is well known that valgrind lags behind OS X releases, I'm closing this.

@muyinliu
Copy link

muyinliu commented Dec 8, 2013

I try http://people.cs.uchicago.edu/~glk/unlinked/mavergrind.sh(a fix for valgrind by Patch to add support for OS X Mavericks (v4)? URL: http://bugsfiles.kde.org/attachment.cgi?id=83590)

and compile succeed.

But running valgrind I got this error message:
valgrind: Unknown/uninstalled VG_PLATFORM 'amd64-darwin'

@nddrylliog
Copy link
Contributor

I'm successfully using valgrind-3.10.0.SVN (fresh from today) on OSX 10.9 Mavericks, installed via homebrew.

I adjusted the valgrind formula so that patches look like:

def patches
  # v4 of patch for Mavericks support, cf. https://bugs.kde.org/show_bug.cgi?id=326724
  { :p0 => 'http://bugsfiles.kde.org/attachment.cgi?id=83590' }
end

And I installed with

brew install --HEAD valgrind

I'm mostly using --tool=callgrind, but as far as I can tell, it works relatively well. I don't know if this warrants a homebrew pull request, though, as it is an experimental patch by Diego Giagio on bugs.kde.org - but since fellow valgrind users will probably end up in this thread, I thought I'd report my findings.

@zittix
Copy link

zittix commented Jan 3, 2014

@jacknagel Please consider the above comment.

@frerich
Copy link

frerich commented Jan 6, 2014

@nddrylliog Thanks for mentioning this! Just saved me some time. +1

@wtn
Copy link

wtn commented Jan 12, 2014

A notice for people installing with the --HEAD option:

Be patient, because downloads from their SVN are slow and the repository is 40+MB.

@kathgironpe
Copy link

@wtn think it isn't a download issue as compiling doesn't work.

@wtn
Copy link

wtn commented Jan 18, 2014

@katgironpe I was able to compile using the @nddrylliog patch (as shown above).

I ended up using Valgrind on Debian (under VirtualBox) because the version that successfully compiled didn't produce the output I expected.

@kathgironpe
Copy link

@wtn read similar comments about Valgrind not working as expected. Thanks for the info. Would likely use Ubuntu when I have to.

@mckelvin
Copy link

I've edit the formula based on the patch, can anyone try that
?
https://gist.github.com/mckelvin/8514475#file-formula_valgrind-rb

# step1: brew edit valgrind
# step2: paste me
# step3: brew install valgrind
require 'formula'

class Valgrind < Formula
  homepage 'http://www.valgrind.org/'
  url 'http://valgrind.org/downloads/valgrind-3.9.0.tar.bz2'
  sha1 '9415e28933de9d6687f993c4bb797e6bd49583f1'
  depends_on 'automake'
  depends_on 'autoconf'
  depends_on 'libtool'

  head do
    url 'svn://svn.valgrind.org/valgrind/trunk'
  end

  depends_on :macos => :snow_leopard

  # Valgrind needs vcpreload_core-*-darwin.so to have execute permissions.
  # See #2150 for more information.
  skip_clean 'lib/valgrind'

  def patches
    # 1: For Xcode-only systems, we have to patch hard-coded paths, use xcrun &
    #    add missing CFLAGS. See: https://bugs.kde.org/show_bug.cgi?id=295084
    # 2: Fix for 10.7.4 w/XCode-4.5, duplicate symbols. Reported upstream in
    #    https://bugs.kde.org/show_bug.cgi?id=307415
    # 3: Fix for 10.9 Mavericks
    p = []
    p << 'https://gist.github.com/raw/3784836/f046191e72445a2fc8491cb6aeeabe84517687d9/patch1.diff' unless MacOS::CLT.installed?
    p << 'https://gist.github.com/raw/3784930/dc8473c0ac5274f6b7d2eb23ce53d16bd0e2993a/patch2.diff' if MacOS.version == :lion
    p << 'https://gist.github.com/mckelvin/8514475/raw/1939e5dfeb1dfc2974582f0dbbf5e3aaeb46d17a/valgrind-3.9.0-mavericks.patch' if MacOS.version == :mavericks
    return p
  end

  def install
    args = %W[
      --disable-dependency-tracking
      --prefix=#{prefix}
    ]
    if MacOS.prefer_64_bit?
      args << "--enable-only64bit" << "--build=amd64-darwin"
    else
      args << "--enable-only32bit"
    end

    system "./autogen.sh"
    system "./configure", *args
    system "make"
    system "make install"
  end

  def test
    system "#{bin}/valgrind", "ls", "-l"
  end
end

@wtn
Copy link

wtn commented Jan 20, 2014

@mckelvin Your formula compiles for me on Mavericks.

The behavior is still different from Debian/Ubuntu, which perhaps is not surprising given the message in the output from Valgrind:

==19000== WARNING: Support on MacOS 10.8/10.9 is experimental and mostly broken.
==19000== WARNING: Expect incorrect results, assertions and crashes.
==19000== WARNING: In particular, Memcheck on 32-bit programs will fail to
==19000== WARNING: detect any errors associated with heap-allocated data.

@MikeMcQuaid
Copy link
Member

@mckelvin Please submit a pull request.

@mckelvin
Copy link

@wtn it's always an unstable one, but anyway most of the time it works.

@fredericgermain
Copy link

Hi there,
Just a copy of my message on kde bugzilla : https://bugs.kde.org/attachment.cgi?id=85889
Patches : https://bugs.kde.org/show_bug.cgi?id=326724

I made a series of patches for Darwin 10.9, adding new syscalls or renaming some anonymous ones, and a few other improvements. I believe it works much better with these.

They are to be applied on current SVN trunk, after applying Diego Giagio's patch.

Could you try them and validate it's working better with them ?
I don't really know how to patch a recipe, but if no one can, I'll look how to make one...

Thanks,


You can find them on my homebrew branch there for the git friendly people (it's a messy and unofficial import, I forgot to change emails in valgind import, so fork it at your own risk please) :
https://github.com/fredericgermain/valgrind/tree/homebrew

@gangleader
Copy link

@kathgironpe
Copy link

@gangleader thanks but that's for macports. Valgrind + homebrew works now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests