The receptivity of a laminar boundary-layer flow to small-amplitude wall roughness is investigated on an ONERA-D swept aerofoil by introducing a dedicated transfer function from small-amplitude wall displacements to full-state velocity perturbations. The singular value decomposition of this operator for a given spanwise wavenumber provides optimal wall roughness and flow responses that maximise an input–output gain. At the most receptive spanwise wavenumber, the optimal response is a cross-flow mode associated with an optimal roughness located close to the attachment line and presenting a wavy shape with a wavevector nearly orthogonal to the external streamlines. The method therefore allows direct identification of the location and structure (chordwise and spanwise wavenumbers) of the most receptive roughness. For various given wall roughness shapes and locations (periodic or compact in the chordwise and/or spanwise directions), an approximation of the response based on the dominant optimal response is shown to accurately match the total response downstream of the roughness. The method therefore allows a straightforward computation of the response of the flow to any given small-amplitude roughness.