violations of dietary laws permitted if necessary for survival?

from the staff report found here.

My question pertains to the applicability of this exception in the face of religious persecution. In the apocryphal book 4 Maccabees, we read that

Clearly we have the threat of death, so the exception noted by Dex could be invoked, allowing the Hebrews their survival at the cost of transgressing the law. In this case, not just the dietary law would have been broken, but also the first commandment, since the food was sacrificed to idols. The outcome of the story, however, has none of the Hebrews transgressing the law, and all being put to death as promised.

It must be noted that the story had to end that way, for the purpose of the narrative was to establish the philosophical conclusion that “devout reason is sovereign over the emotions” ( 4 Maccabees 1: 1, NRSV ).

Does this story, even if not canonical, establish a precedent that the exception noted by Dex should not be invoked when one is faced with religious persecution? Would the exception have been admissable if the food had not been sacrificed to idols? Did the rabbis establish the exception to their dietary law after this story took place, making this discussion irrelevant?

The question could also be put to the Muslim community. In those societies where apostasy is punishable by death, does violating the dietary law under religious persecution constitute apostasy, leading to a death that might be no better than the alternative, had a Muslim held firm to his faith and suffered at the hands of his persecutors? Or may a Muslim transgress the dietary law to save his life, maintaining his standing in the community of the faithful so long as he renounce not his faith?

The story as given does indeed correctly reflect what Jewish law has to say on this subject (and so do similar episodes from that era, such as II Macc. 6:18ff). In this post (and the following discussion in that thread), I summarized the conditions under which this exception - “violate Jewish law to save your life” - doesn’t apply; one of them is at a time of government-sanctioned religious persecution, and of course Antiochus’ decrees were exactly that.