A shape-function independent relation is derived between the partialB → X u l −ν decay rate with a cut on P + = E X − | P X | ≤ ∆ and a weighted integral over the normalizedB → X s γ photon-energy spectrum. The leading-power contribution to the weight function is calculated at next-to-next-to-leading order in renormalization-group improved perturbation theory, including exact two-loop matching corrections at the scale µ i ∼ m b Λ QCD . The overall normalization of the weight function is obtained up to yet unknown corrections of order α 2 s (m b ). Power corrections from phase-space factors are included exactly, while the remaining subleading contributions are included at first order in Λ QCD /m b . At this level unavoidable hadronic uncertainties enter, which are estimated in a conservative way. The combined theoretical accuracy in the extraction of |V ub | is at the level of 5% if a value of ∆ near the charm threshold can be achieved experimentally.