Mahlab is the spice made from the ground pit of a wild cherry that is used to flavor numerous Greek and Middle Eastern pastries. It is one of those flavors that is largely unfamiliar to western taste buds. If you are in the US, you may have a hard time finding this spice unless you live near a well-stocked specialty food store. If you hunt for mahlab comes up short, you are not alone. There are a few tried and true alternatives out there.
Your best bet: Almond extract and star anise
You will have to adjust this substitute to taste, but you should combine the two flavorings so that there is slightly more of the almond extract than of the star anise. You want the almond flavor at the forefront and the star anise in the background. It is important to remember that both are extremely pungent, so proceed cautiously.
In a pinch: Pure anise extract
Anise can deliver the licorice notes that mahlab lovers want. The extract is widely available but you can make your own without much trouble if you have trouble finding it. The recipe has two ingredients: 2 teaspoons of anise seeds and 6 ounces of vodka. Note that this takes a certain amount of foresight as the assembled ingredients will not be ready to use before 2 months have passed. As with the substitutes above, it is best to try a small amount of this mahlab alternative and adjust until you get the desired taste. The anise flavor will continue to intensify until you remove the anise seeds from the vodka.
One common option is the combination of ground fennel seed and cardamom, both of which may be easier to find that most the options above. Fennel seeds can provide the licorice notes while cardamom provides an intense sweetness that should complement the bread and cookie recipes that call for mahlab.
If you can find bitter almonds, some cooks recommend them as a mahlab replacement. If you live in the US, you may have an especially hard time finding these because of their potential toxicity. The Food and Drug Administration deems both the kernel and the tree illegal.