Regarding Skia Builds

207 views
Skip to first unread message

rav2n

unread,
Jun 16, 2025, 11:50:24 AMJun 16
to Chromium-discuss
Hi,

I'm trying to figure out how to get Skia built locally within the chromium repo
and have a custom standalone executable use the binaries of skia all within the chromium repo (ie, the standalone exec).

Tried building Skia as per:
 https://skia.org/docs/dev/chrome/repo/

then added libs prop to the chromium/src/standalone_exec_dir/BUILD.gn - 
after a bit of messing around, had some linking errors (I'm thinking ABI related - no idea).

The root chromium/src/BUILD.gn only has the following:

group("standalone_exec") {
  deps = [ "//standalone_exec" ]
}

Would like some input and pointers

David Amber “WebDUH LLC” Weatherspoon

unread,
Jul 28, 2025, 12:06:30 PMJul 28
to Chromium-discuss, rav2n
Hey rav2n!

  I totally get the frustration with Skia linking in Chromium - it's one of those things that looks
  simple but has a bunch of gotchas. Here's what's actually happening and how to fix it:

  The Real Issue

  You're hitting ABI mismatches because Chromium's Skia build is heavily customized and uses specific
  compiler flags that your standalone exec isn't inheriting. The 2025 updates made this even trickier
  with the new Graphite backend integration.

  Here's What Actually Works

  1. Your chromium/src/standalone_exec/BUILD.gn should look like this:

  executable("standalone_exec") {
    sources = [
      "main.cc",
      # your other files
    ]

    # THIS IS THE KEY - use Chromium's exact Skia target
    deps = [
      "//skia:skia",           # Main Skia library
      "//base",               # Chromium base (you'll need this)
      "//build/config/compiler:compiler",
    ]

    # Match Chromium's build config exactly
    configs += [
      "//build/config/compiler:chromium_code",
      "//skia:skia_library_configs",  # This is crucial!
    ]

    # If you need GPU features (Graphite backend stuff)
    if (skia_use_metal || skia_use_vulkan) {
      defines += [ "SK_GRAPHITE=1" ]
    }
  }

  2. Build it the right way:

  # From chromium/src/
  gn gen out/Default --args="is_component_build=false"
  ninja -C out/Default standalone_exec

  Why You Were Getting Linking Errors

  The main culprits:
  - Missing skia_library_configs - this contains all the weird Skia-specific flags
  - Component build mismatch - Skia changes behavior between static/shared builds
  - New Graphite backend - 2025 added GPU backend complexity

  Simpler Approach (If Above Fails)

  If you're still having issues, try this minimal version:

  executable("standalone_exec") {
    sources = [ "main.cc" ]
   
    deps = [
      "//third_party/skia",
      "//base:base",
    ]

    # Let Chromium handle the complexity
    configs += [ "//build/config:precompiled_headers" ]
  }

  Test Your Setup

  Create a simple main.cc to verify it works:

  #include "include/core/SkCanvas.h"
  #include "include/core/SkSurface.h"
  #include "base/logging.h"

  int main() {
    auto surface = SkSurface::MakeRasterN32Premul(100, 100);
    if (surface) {
      LOG(INFO) << "Skia works!";
      return 0;
    }
    LOG(ERROR) << "Skia failed to initialize";
    return 1;
  }

  The key insight is that Chromium's Skia isn't just "regular Skia" - it's a heavily modified version
  with custom build flags, especially after the 2025 Graphite integration. You need to inherit those
  exact same build settings.

  Let me know if you're still hitting issues - happy to help debug further!
  I hope all your google developer issues and questions can be treated with the same or better level of respect  :)
  - Reconsumeralization
Reply all
Reply to author
Forward
0 new messages