After reading this posts on Trying to understand libraries and Are internal functions in libraries not covered by linking?.
I think only the internal functions that are really consumed by the calling contract will be inlined. Also, for a library that is not pure internally (as long as it contains non-internal functions, I call it non-pure), even if its internal functions are called in a contract, its interal functions will not be inlined.
I checked with the following example in Remix. After compiling the following code, I searched the assembly code. I found "_num+8" (the internal function in the pure library l_Intl is called), but neither "_num+2" (the internal function in the pure library l_Intl, but no called) nor "numxxx" (which presents in the non-pure library l_Pub) presents in the assembly code.
You can also try with the follwing example.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
library l_Intl {
struct lstore { uint num; }
function set (lstore storage self, uint _num) internal {
self.num = _num+8;
}
function setxxx (lstore storage self, uint _num) internal {
self.num = _num+2;
}
}
contract c_Intl {
l_Intl.lstore cstore;
function setxxx (uint _num) public { l_Intl.setxxx(cstore, _num); }
}
library l_Pub {
struct lstore { uint numxxx; }
function set (lstore storage self, uint _num) public{
self.numxxx = _num;
}
function setxxx (lstore storage self, uint _num) internal{
self.numxxx = _num+2;
}
}
contract c_Pub {
l_Pub.lstore cstore;
function set (uint _num) public { l_Pub.set(cstore, _num); }
function setxxx (uint _num) public { l_Pub.setxxx(cstore, _num); }
}