How to use randen_engine under src\third_party\blink\renderer\core

30 views
Skip to first unread message

FlyingEagle

unread,
Dec 11, 2022, 7:27:01 AM12/11/22
to abseil-io
Hi,

I have not found real example in Chromium 

what I am trying to use is:
typedef absl::randen_engine<uint64_t> FarblingPRNG;

int BraveSessionCache::FarbledInteger(FarbleKey key,
                                      int spoof_value,
                                      int min_random_offset,
                                      int max_random_offset) {
  if (farbled_integers_.count(key) == 0) {
    FarblingPRNG prng = MakePseudoRandomGenerator(key);
    farbled_integers_[key] =
        prng() % (1 + max_random_offset - min_random_offset) +
        min_random_offset;
  }
  return farbled_integers_[key] + spoof_value;
}


file structure is as below:


but failed
c:\code\chromium_git\chromium\src>ninja -C out\Release_GN_x86 cef
ninja: Entering directory `out\Release_GN_x86'
[0/1] Regenerating ninja files
[1/335] LINK v8_context_snapshot_generator.exe v8_context_snapshot_generator.exe.pdb
FAILED: v8_context_snapshot_generator.exe v8_context_snapshot_generator.exe.pdb
ninja -t msvc -e environment.x86 -- ..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\12.0.0\lib\windows "-libpath:..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\ATLMFC\lib\x86" "-libpath:..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\lib\x86" "-libpath:..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x86" "-libpath:..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x86" /OUT:./v8_context_snapshot_generator.exe /PDB:./v8_context_snapshot_generator.exe.pdb @./v8_context_snapshot_generator.exe.rsp
lld-link: error: undefined symbol: public: __thiscall absl::random_internal::Randen::Randen(void)
>>> referenced by .\..\..\third_party\blink\renderer\core\farbling\brave_session_cache.cc:357
>>>               blink_core.lib(brave_session_cache.obj):(public: bool __thiscall brave::BraveSessionCache::AllowFontFamily(class blink::WebContentSettingsClient *, class WTF::AtomicString const &))
>>> referenced by .\..\..\third_party\blink\renderer\core\farbling\brave_session_cache.cc:343
>>>               blink_core.lib(brave_session_cache.obj):(public: int __thiscall brave::BraveSessionCache::FarbledInteger(enum brave::FarbleKey, int, int, int))
>>> referenced by .\..\..\third_party\blink\renderer\core\farbling\brave_session_cache.cc:329
>>>               blink_core.lib(brave_session_cache.obj):(public: class WTF::String __thiscall brave::BraveSessionCache::FarbledUserAgent(class WTF::String))
>>> referenced 1 more times

lld-link: error: undefined symbol: public: static void __cdecl absl::random_internal::RandenSlow::Generate(void const *, void *)


seems that abseil-cpp obj files are not generated in out folder.

then I add deps as


but failed as below
c:\code\chromium_git\chromium\src>ninja -C out\Release_GN_x86 cef
ninja: Entering directory `out\Release_GN_x86'
[0/1] Regenerating ninja files
ERROR Unresolved dependencies.
//third_party/blink/renderer/core:core(//build/toolchain/win:win_clang_x86)
  needs //third_party/abseil-cpp:abseil-cpp(//build/toolchain/win:win_clang_x86)


how to use abseil-cpp in a correct way? under src\third_party\blink\renderer\core

thx

2C666902@D1876237.89CC9563.png.jpg
0AD58708@92C2F80F.89CC9563.png.jpg

Derek Mauro

unread,
Dec 11, 2022, 11:22:09 AM12/11/22
to FlyingEagle, abseil-io
For Chromium, I think the correct answer is don't use Abseil's Random library at all. Please see https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-features.md#Random-banned.

Hypothetically, if this were not Chromium, randen_engine is defined in absl/random/internal/randen_engine.h. The "internal" in the path means that it should not be used directly at all. Instead, use absl::BitGen. absl::BitGen makes no claims about the underlying engine, and we may delete or replace randen_engine at any time. See https://abseil.io/docs/cpp/guides/random for more information about supported use.

The error you are seeing looks like a linker error, which generally means a dependency is missing somewhere. I don't know anything about Chromium's build system, so you really need to do this, you will have to get help from Chromium.

--
You received this message because you are subscribed to the Google Groups "Abseil.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abseil-io+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abseil-io/tencent_8038B0A1CADE2CB22BBF28ADEA65C0B40608%40qq.com.

wei cheng

unread,
Dec 11, 2022, 8:11:32 PM12/11/22
to Abseil.io
very kind and detailed replay, thanks, I'll try to turn to chromium groups or check if there are some other solution.
Reply all
Reply to author
Forward
0 new messages