Closed Bug 861425 Opened 11 years ago Closed 10 years ago

Build clang static analyzer on Mac

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla32

People

(Reporter: ggp, Assigned: ehsan.akhgari)

References

Details

Attachments

(1 file, 1 obsolete file)

      No description provided.
Here's my attempt at making the clang plugin build on Mac.

It's been tested under OSX 10.8.3 with clang trunk r179064, and also on Linux with clang 3.2 to try to catch any regressions. It seems like the clang included with XCode doesn't support plugins, so it is actually necessary to build it from source on OSX.
Attachment #737027 - Flags: feedback?(Pidgeot18)
Can you try running this on the try servers as well?
Comment on attachment 737027 [details] [diff] [review]
Build clang static analyzer on OSX

Review of attachment 737027 [details] [diff] [review]:
-----------------------------------------------------------------

::: build/clang-plugin/Makefile.in
@@ +9,2 @@
>  VPATH		 := @srcdir@
> +PLUGIN := @plugin@

On the whole, I'd rather keep the variables we get from configure closer to the stuff found in config/autoconf.mk; instead of passing in a plugin flag, pass in DLL_SUFFIX and say PLUGIN := libclang-plugin.$(DLL_SUFFIX)

CXXLIBFLAGS should probably be DSO_LDOPTS (although this needs to be different from Mozilla's DSO_LDOPTS eventally, I guess, since we don't want -Wl,-z,defs).
Attachment #737027 - Flags: feedback?(Pidgeot18) → feedback+
Guilherme, are you still planning to work on this?
Flags: needinfo?(ggoncalves)
FWIW this fixes the build for me locally, I'd be glad to help get this landed.
(In reply to :Ehsan Akhgari (lagging on bugmail, needinfo? me!) from comment #4)
> Guilherme, are you still planning to work on this?

Not for the foreseeable future, sorry :/

I remember this did fix the build locally for me back then, but I never got a green try run with it. Perhaps things will work better now that it's been a year.
Flags: needinfo?(ggoncalves)
OK, thanks, I'll give it a shot!
Assignee: nobody → ehsan
FWIW this doesn't build on Mac on try because we try to link against the 64-bit libraries during our x86 build pass of the universal build:

ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMBitReader.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMMCParser.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMAsmParser.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMAnalysis.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMTarget.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMMC.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMObject.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMCore.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libLLVMSupport.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangFrontend.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangDriver.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangSerialization.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangParse.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangSema.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangAnalysis.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangEdit.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangAST.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangLex.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangBasic.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /builds/slave/try-osx64-00000000000000000000/build/clang/lib/libclangASTMatchers.a, file was built for archive which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
  "clang::Type::getUnqualifiedDesugaredType() const", referenced from:
      clang::RecursiveASTVisitor<(anonymous namespace)::MozChecker>::TraverseType(clang::QualType) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::NonHeapClassChecker::run(clang::ast_matchers::MatchFinder::MatchResult const&) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::NonHeapClassChecker::noteInferred(clang::QualType, clang::DiagnosticsEngine&) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::StackClassChecker::run(clang::ast_matchers::MatchFinder::MatchResult const&) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::StackClassChecker::noteInferred(clang::QualType, clang::DiagnosticsEngine&) in clang-plugin.o
      (anonymous namespace)::getClassAttrs(clang::CXXRecordDecl*) in clang-plugin.o
      clang::ast_matchers::internal::matcher_returns0Matcher::matches(clang::FunctionDecl const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const in clang-plugin.o
      ...
  "clang::Type::getAsCXXRecordDecl() const", referenced from:
      clang::RecursiveASTVisitor<(anonymous namespace)::MozChecker>::WalkUpFromCXXRecordDecl(clang::CXXRecordDecl*) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::NonHeapClassChecker::noteInferred(clang::QualType, clang::DiagnosticsEngine&) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::StackClassChecker::noteInferred(clang::QualType, clang::DiagnosticsEngine&) in clang-plugin.o
      (anonymous namespace)::getClassAttrs(clang::CXXRecordDecl*) in clang-plugin.o
      clang::ast_matchers::internal::matcher_stackClassAggregate0Matcher::matches(clang::QualType const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const in clang-plugin.o
      clang::ast_matchers::internal::matcher_nonheapClassAggregate0Matcher::matches(clang::QualType const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const in clang-plugin.o
  "clang::Decl::getAttrs() const", referenced from:
      clang::RecursiveASTVisitor<(anonymous namespace)::MozChecker>::WalkUpFromCXXRecordDecl(clang::CXXRecordDecl*) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::NonHeapClassChecker::run(clang::ast_matchers::MatchFinder::MatchResult const&) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::NonHeapClassChecker::noteInferred(clang::QualType, clang::DiagnosticsEngine&) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::StackClassChecker::run(clang::ast_matchers::MatchFinder::MatchResult const&) in clang-plugin.o
      (anonymous namespace)::DiagnosticsMatcher::StackClassChecker::noteInferred(clang::QualType, clang::DiagnosticsEngine&) in clang-plugin.o
      (anonymous namespace)::getClassAttrs(clang::CXXRecordDecl*) in clang-plugin.o
      clang::ast_matchers::internal::matcher_heapAllocator0Matcher::matches(clang::FunctionDecl const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const in clang-plugin.o
      ...
Attachment #737027 - Attachment is obsolete: true
Comment on attachment 8427494 [details] [diff] [review]
Build the clang plugin on Mac; r=jcranmer

This is green on both Linux and OSX debug.  It doesn't build on OSX opt because of the universal build issue, but we only need the debug to be green before we can turn this on on TBPL! \o/

https://tbpl.mozilla.org/?tree=Try&rev=c2e8d9108e9a
Attachment #8427494 - Flags: review?(Pidgeot18)
Blocks: 1015018
Attachment #8427494 - Flags: review?(Pidgeot18) → review+
https://hg.mozilla.org/mozilla-central/rev/288387f37b70
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: