how to instrument pdfium with afl-clang?

232 views
Skip to first unread message

com.andr...@gmail.com

unread,
Mar 7, 2018, 4:32:43 AM3/7/18
to pdfium
Hi,

I have downloaded the pdfium source. From documentation, it seems i have to use ninja to compile pdfium. Is there any docs/links on how to instrument pdfium using afl-clang?

Dan Sinclair

unread,
Mar 7, 2018, 10:15:18 AM3/7/18
to com.andr...@gmail.com, pdfium
I believe ninja will honour the CC and CXX environment variables if they specify a different compiler, but I've never tried.

dan


On Wed, Mar 7, 2018 at 4:32 AM, <com.andr...@gmail.com> wrote:
Hi,

I have downloaded the pdfium source. From documentation, it seems i have to use ninja to compile pdfium. Is there any docs/links on how to instrument pdfium using afl-clang?

--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+unsubscribe@googlegroups.com.
To post to this group, send email to pdf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/7f149539-abbd-4593-9793-3bf143c9e53f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Mathias

unread,
Mar 7, 2018, 1:29:24 PM3/7/18
to Dan Sinclair, pdfium
Hello Dan,

I  tried passing CC and CXX to ninja but doesn't seems like it worked.

"CC=AFL_CC CXX=AFL_CXX ninja -C out/release"

Dan Sinclair

unread,
Mar 7, 2018, 2:01:51 PM3/7/18
to David Mathias, Dan Sinclair, pdfium
I'm not sure in that case, it's possible our gn files don't set things up so it can use the env, or it's possible ninja uses the env in a different fashion.

dan

Martin Sandsmark

unread,
Mar 8, 2018, 3:53:55 AM3/8/18
to Dan Sinclair, David Mathias, pdfium
Hi!


On 7 March 2018 at 20:01, Dan Sinclair <dsin...@chromium.org> wrote:
> I'm not sure in that case, it's possible our gn files don't set things up so
> it can use the env, or it's possible ninja uses the env in a different
> fashion.

At least for cross-compiling with Yocto we need to create a custom
toolchain file for gn and inject that into the build, just setting
standard environment variables don't seem to help.

We do something very much like this when building pdfium:
https://github.com/OSSystems/meta-browser/blob/master/recipes-browser/chromium/gn-utils.inc

In general it would be nice to get support for a more normal build
system upstream, but I've just assumed that's a no-go so I haven't
submitted any patches for that. I know Qt used to automatically
generate .pri files from the .gyp files to be able to cross-compile
etc. (I'm not sure what they do now that gyp is replaced with gn), and
qtpdfium maintains .pri files by hand, so it's something that would
benefit more projects, though.


--
Martin Sandsmark
Chief Technical Officer
+47 980 33 988

https://remarkable.com
Pilestredet 75c, 0354 Oslo - Norway

Dan Sinclair

unread,
Mar 8, 2018, 9:53:01 AM3/8/18
to Martin Sandsmark, Dan Sinclair, David Mathias, pdfium
PDFium only supports GN to build at this point. We supported both GN and GYP for a while and it .... was painful. Having to support multiple build systems means we'd need to make sure all our testing and infra works with all of those build systems as well.

There is flag you can pass to gn gen to output the build data in JSON format. You can then create tools to convert that data into other build files. I believe there were gn to bazel scripts that were being worked on but I don't know the status.

If there are changes to our GN configs that can make compiling with other compilers easier we're happy to review the patches. Note, the build/ directory is pulled from Chromium so any changes in there would have to go through the chromium reviewers.

dan

rsippl

unread,
Mar 8, 2018, 7:24:16 PM3/8/18
to pdfium
If you'd like to use CMake with PDFium, give this a try:
I'm using it in a PDFium based project on Mac, as CMake gives me quite some flexibility, e.g. tracing through PDFium code using IDEs like CLion and Qt Creator, using my own Clang build with LeakSanitizer support, building PDFium + v8 in a static lib etc.
The CMakeLists.txt needs to be maintained by hand, but it's not a big deal if you keep an eye on the git log of a few files, most notably BUILD.gn and third_party/BUILD.gn.
No Skia or XFA support (yet). V8 works fine for me.

pdknsk

unread,
Mar 27, 2018, 6:15:48 PM3/27/18
to pdfium
I've also run into a similar problem. Many other projects using GN (like skia) support setting cc and cxx (plus extra_cflags and more) variables in args.gn – unfortunately pdfium does not. I don't know how difficult it is to hack this in. The only variable approaching this is clang_base_path.
Reply all
Reply to author
Forward
0 new messages