Generate reports using Clang Analyzer - scan-build - ios

I am new to Clang analyzer and I am trying to generate reports using scan-build. While using the scan-build as below:
./scan-build --use-analyzer=/build/Debug+Asserts/bin/clang -v -o report_location sample.xcodeproj
I am always getting the below error:
scan-build: Using `/build/Debug+Asserts/bin/clang' for static analysis ; Can't exec "sample.xcodeproj":
Permission denied at ./scan-build line 1029. ;
scan-build: Removing directory 'report_location/2013-06-25-1' because it contains no reports. ;
scan-build: No bugs found.
Please help me resolving this issue.

The way scan build works is it either
invokes the command you provide e.g. make
executes the file that you provide e.g. some shell script
And when it does that it overrides the $CC environment variable to point to another script from where it forks two processes. In one the compiler runs as regular build and in another static-analyzer runs to generate report.
You are getting this error because 'sample.xcodeproj' is not an executable.
I'm not very familiar with xcode but I think if you chmod +x sample.xcodeproj then things should work.
clang-static analyzer can be integrated with xcode as well:
http://clang-analyzer.llvm.org/xcode.html
https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode_User_Guide/000-About_Xcode/about.html#//apple_ref/doc/uid/TP40010215-CH3-SW17

Related

Bazel giving "open_proc" error 21 running embedded command

I'm working on creating a Bazel extension for Haxe and while I've had some initial success in getting things to build, I've hit a roadblock and I'm not sure what the right way around it is.
In Haxe if you declare a dependency on a Haxelib in your build.hxml file, when you perform the build the Haxe compiler will go grab that Haxelib from the internet and install it locally if you don't already have it, using a program named "haxelib". It seems that this process is being blocked by the Bazel sandbox, but I haven't been able to find much documentation on how the sandboxing works, if this is expected, and if there's a way around it. I'm currently working in Windows 10; this is the error that I'm getting:
$ bazel build //:neko-lib --verbose_failures
INFO: Analyzed target //:neko-lib (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: D:/repo/validation/BUILD:3:13: HaxeCompile neko/validation.n failed (Exit 1): haxe.exe failed: error executing command
cd C:/users/user/_bazel_user/s6xipia4/execroot/__main__
external/haxe_windows_amd64/haxe.exe bazel-out/x64_windows-fastbuild/bin/build.hxml
Execution platform: #local_config_platform//:host
Unix.Unix_error(21, "open_proc", "haxelib path hx3compat")
Target //:neko-lib failed to build
INFO: Elapsed time: 1.705s, Critical Path: 0.62s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
hx3compat is the name of the haxelibthat I'm trying to load. Error 21 seems to be "is a directory" but I'm not exactly sure what's actually being complained about. Here's the run action that I'm using:
ctx.actions.run(
outputs = [out],
inputs = inputs,
executable = haxe_cmd,
arguments = [args],
env = env,
mnemonic = "HaxeCompile",
)
haxe_cmd points the haxe.exe file, while the inputs are:
bazel-out/x64_windows-fastbuild/bin/build.hxml (the build file I'm building)
external/haxe_windows_amd64/haxe.exe
external/haxe_windows_amd64/haxelib.exe
Any ideas on things I can try to get around this issue?
Update: I wrote a rule today that runs the command in question (haxelib path hx3compat) and that works, so I think this is an error with invoking that command - not with the command itself.
The particular error that I was getting - Unix error 21 - was caused by the shell that Bazel creates not having the COMSPEC environment variable: see here and here for more details. Adding that variable to the environment via the --action_env=COMSPEC command line got me past that error. However the command shell that gets spawned by the Haxe process cannot handle symlinks, and so has a lot of trouble trying to access the directories brought in by Bazel, so I think using haxe via this route will end up being a lost cause. Just for the record though, I was able to get the haxelib command itself to run through the haxe process, so the answer for this question is to ensure the COMSPEC variable is set.

How does AOSP build system produce .rsp files and how to get them?

According to How does AOSP 9.0 build system link the executable? and What does # mean in this clang command in AOSP build log? , when linking a module, AOSP seems to produce a .rsp file that contains all the obj files that the module need,and pass the file name as a parameter to the link command, for example:
prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ /OpenSource/Build/Android/9.0.0_r30/soong/.intermediates/bionic/libc/crtbegin_so/android_x86_64_core/crtbegin_so.o #/OpenSource/Build/Android/9.0.0_r30/soong/.intermediates/frameworks/base/libs/hwui/libhwui/android_x86_64_core_shared/libhwui.so.rsp ......
But the .rsp files seems to be removed after build.
The question is, how are these file generated and how to get these files? This may require to learn and modify the build scripts which is out of reach for me.
There maybe the answer for you, read the ninja build manual , in that manual .rsp file mentioned.
https://ninja-build.org/manual.html
the following is info that I copy out.
rspfile, rspfile_content
if present (both), Ninja will use a response file for the given command, i.e. write the selected string (rspfile_content) to the given file (rspfile) before calling the command and delete the file after successful execution of the command.
This is particularly useful on Windows OS, where the maximal length of a command line is limited and response files must be used instead.

TFS2015 Build fails on all Command Line Commands with 'file not found'

In Team Foundation Server 2015 Build (on-premise), I'm having issues running simple command line commands. All Command Line tasks simply fail with the following error: "File not found: ".
Take for example the following build definition:
This is executed using an on-premise Build Agent and will fail with the following exception in the logs:
BUILD FAILED
2016-01-20T12:04:47.5127709Z ##[warning]Filename doesn't indicate a full path to a executable file.
2016-01-20T12:04:47.5127709Z Executing the following commandline. (workingFolder = D:\_work\2\s)
2016-01-20T12:04:47.5127709Z date
2016-01-20T12:04:47.5127709Z Error message highlight pattern:
2016-01-20T12:04:47.5127709Z Warning message highlight pattern:
2016-01-20T12:04:47.5439748Z ##[error]File not found: date
Of course this is a simplified example where I simply want to output the current date using the date /t command. But the same problem occurs with all general command line commands which I've tried, such as dir, time, path etc. The MSDN does not provide any troubleshooting info on it, other than that the tool executed must reside in the PATH variable.
The issue is not specific to one build definition or repo; it can be reproduced on others as well.
The builds run as the built-in svc_tfsbuild account.
I'm perhaps thinking this is either a simple setting, or - wildly guessing - an issue related to rights, but cannot find any documentation where to look or what to check. Any help would be appreciated.
It appears this is a known issue on MS Connect as well.
In short a MSFT mentions the following:
Commands that are built-in to command prompt don't work. Anything resolvable based on your PATH/PATHEXT will work.
In the comment from 27 Oct, 2015 it is stated that this will be fixed in the next sprint. The mentioned workaround for now is simply executing cmd.exe first and provide the rest as arguments.
Using the example from the original question this would lead to:
Tool: cmd.exe
Arguments: /c "date /t"
And I can indeed confirm this works.

Convert iOS project to 64 bit using ConvertCocoa64 script

I need to convert my iOS project to 64-bit friendly (to get rid of compiler warnings, as in this question. The solution apparently is to run ConvertCocoa64.
I've managed to locate ConvertCocoa64 (which is no longer included in /Developer/Extras/64BitConversion/ConvertCocoa64) as the Apple docs suggest, but here (search for Auxiliary Tools)
So I've download the script. But my question is, how do I run this on my project? Please assume a total newbie level of knowledge here when it comes to the terminal and running scripts. Do I drop the script inside my project folder and just double click it? Or do I access it from the terminal? The docs say run this command:
/Developer/Extras/64BitConversion/ConvertCocoa64 `find . -name '*.[hm]' | xargs`
But since that folder doesn't exist, where do I run it?. I tried dropping the script in the Developer folder, but when I type ConvertCocoa64 it says command not found.
Find where the command is located now. You'll want to run it in the terminal using the full path to the command, as in your example, just with the real path.
A good way to get the full path is to locate the command in the Finder and drag it to an open terminal window - this also "escapes" any spaces in the path for you. The easiest way to hit all your files as arguments to the command is to cd (change directory) to your project first (in the terminal).
This should get you set up to follow the directions you have.
If I'm not mistaking, to run script, you should place dot . before command. Doesn't really matters, where script is situated as long, as it doesn't rely on it heavily
> cd ~/path/to/script/dir/
> ./ConvertCocoa64 ...

Any ZMQ bindings for Erlang on Windows?

Is it possible to use Erlang with ZMQ on Windows? I have tried to use erlzmq2, but rebar fails to compile it with cryptic linker errors. Of course i can invest some time and investigate makefiles, but maybe other way exists?
Update
Whose who are interested in compilation errors can download latest erlang for windows and try to build erlzmq2 (Visual Studio 2012 compiler, msys sh and make). Error looks like:
cl : Command line error D8021 : invalid numeric argument '/Wl,-DLL,-IMPLIB:.libs
\zmq.dll.lib'
Makefile:541: recipe for target 'libzmq.la' failed
make[3]: *** [libzmq.la] Error 2
Please note that other erlang libs are compiling with this setup without any problems.
Your problem lies in compiling ZeroMQ for Windows. You haven't actually gotten to any Erlang yet. Here are some of the clues that tell you this:
Makefile:541: recipe for target 'libzmq.la' failed
This line says there's a problem on line 541 of the Makefile. But in erlzmq2, you can see that neither the main Makefile nor the c_src Makefile (which is what would build libzmq.la) has anything close to that many lines.
make3: * [libzmq.la] Error 2
The [3] means that you're 3 invocations deep into Make. Specifically, you started at the top-level Makefile, which called Rebar, which ran make -C c_src, which downloads ZeroMQ version 3.2.2 and tries to do a ./configure && make
To fix this Unix-style, go into the deps directory of erlzmq2 and figure out how to correctly compile ZeroMQ. Hopefully, you will just need to pass some arguments to configure. Then you can edit c_src/Makefile and set ZMQ_FLAGS to whatever you had to do for configure, clean, and make.
To fix it more Windows-style, follow the Windows build instructions for ZeroMQ. Put the compiled libzmq under deps and just edit the c_src Makefile to a no-op.
Finally, if you don't actually need to run this code on Windows, but are just using Windows as your development environment, I think you'll have the easiest time by running the build inside a Linux VM (not a hard thing at all with tools like Vagrant). Sorry, but Unix is the real system for this stuff; Windows support is an afterthought.

Resources