וְלַֽנַּעֲרָה֙ לֹא־תַעֲשֶׂ֣ה דָבָ֔ר אֵ֥ין לַֽנַּעֲרָ֖ה חֵ֣טְא מָ֑וֶת כִּ֡י כַּאֲשֶׁר֩ יָק֨וּם אִ֤ישׁ עַל־רֵעֵ֙הוּ֙ וּרְצָח֣וֹ נֶ֔פֶשׁ כֵּ֖ן הַדָּבָ֥ר הַזֶּֽה
Do not do anything to the girl; there is not to the girl a sin of death, for just as one would rise up against his friend and murder his soul, so, too, is this thing.
Just like one must give up his life rather than murder, so, too, one must give up his life rather than have illicit relations.
Now, this passuk is taught in the context of specifically rape, not just any immoral relationship. On what basis, then, does the Gemara assume that this should be extended to any immoral relationship? Perhaps it's only rape for which one must give up his life, but other immoral relations would be permissible on pain of death, especially since the general rule is taught in the context of general immorality.